network_distance#
- network_distance(network_A, network_B, weight_A=None, weight_B=None, distance_metric='euclidean', distance_kwargs={})#
Calculate the distance between two networks providing a quantitative measure of the similarity between them.
- Parameters:
- network_Anetworkx.Graph
A networkx graph representing the first network.
- network_Bnetworkx.Graph
A networkx graph representing the second network.
- weight_Astr, optional
Edge weights of network A to be used in distance calculation, defaults to ‘Distance’.
- weight_Bstr, optional
Edge weights of network B to be used in distance calculation, defaults to ‘Distance’.
- distance_metricstr, optional
Method used to compute the distance between networks. Options are ‘edit’, ‘deltacon_0’, ‘netlsd’, ‘wwl kernel’, ‘euclidean’, ‘manhattan’, ‘k spectral laplacian’, and ‘k spectral adjacency’. Defaults to ‘euclidean’.
- distance_kwargsdict, optional
Additional keyword arguments for specific network distance metrics.
- Returns:
- float
Distance between the two networks.
- Raises:
- ValueError
If the provided distance metric is not implemented. If the provided networks are not networkx graphs. If the provided edge weights are not present in the networks. If the networks do not have the same number of nodes for certain distance metrics. If specific parameters for certain distance metrics are invalid.
Notes
If the Wasserstein Weisfeiler-Lehman (wwl) kernel is used, networks passed must be stored within the domains of a muspan object.
The following keyword arguments (kwargs) are used for specific distance metrics:
- deltacon_epsfloat, optional
Epsilon value for the DeltaCon similarity metric. If not provided, it is computed as 1/max(spectral radius of the adjacency matrices).
- netlsd_timefloat, optional
Time parameter for the NetLSD metric. Defaults to 5.
- netlsd_timestepfloat, optional
Timestep parameter for the NetLSD metric. Defaults to 1.
- wwl_iterationsint, optional
Number of iterations for the Wasserstein Weisfeiler-Lehman kernel. Defaults to 5.
- wwl_label_featureslist or str, required
List of label features to compare for the Wasserstein Weisfeiler-Lehman kernel.
- wwl_domainslist, required
List of two muspan domains that contain the respective networks A and B for the Wasserstein Weisfeiler-Lehman kernel.
- kint, optional
Number of eigenvalues to compute for the k spectral laplacian and k spectral adjacency metrics. Defaults to 5.