Directed Graphs#

Not all backbone methods support directed graphs. This guide explains which methods work with directed graphs and how their behavior differs.

Supported methods#

The following methods support both directed and undirected graphs:

Statistical methods (all 6):

disparity_filter(), noise_corrected_filter(), marginal_likelihood_filter(), ecm_filter(), lans_filter(), multiple_linkage_analysis()

Structural (2 of 10):

global_threshold_filter(), strongest_n_ties()

Hybrid methods:

glab_filter()

Proximity methods (all 12):

All proximity scoring functions work with directed graphs.

Filters (all 4):

threshold_filter(), fraction_filter(), boolean_filter(), consensus_backbone()

Measures (all 7):

All evaluation functions work with directed graphs.

Undirected-only methods#

The following methods raise NetworkXNotImplemented when given a directed graph:

Behavior differences#

For statistical methods on directed graphs, the p-value computation uses the out-degree and out-strength of the source node. noise_corrected_filter() uses the source’s out-strength and the target’s in-strength, and multiple_linkage_analysis() fits each node’s out-links only. For proximity methods on directed graphs, neighborhoods are defined using successors.

glab_filter() follows Section 2.3 of Zhang et al. (2014): each link (i, j) gets an out-importance from the shortest paths that leave i through it (null model on the out-degree of i) and an in-importance from the shortest paths that reach j through it (null model on the in-degree of j); glab_pvalue is the smaller of the two. On a symmetric directed graph this equals the undirected p-value.

Example#

import networkx as nx
import nx_backbone as nb

# Create a weighted directed graph
G = nx.DiGraph()
G.add_weighted_edges_from([
    (0, 1, 5.0), (0, 2, 3.0), (0, 3, 1.0),
    (1, 0, 2.0), (1, 2, 4.0),
    (2, 3, 6.0),
])

# Statistical methods work on directed graphs
H = nb.disparity_filter(G)
backbone = nb.threshold_filter(H, "disparity_pvalue", 0.05)