add_similarity_weight_to_edges#

add_similarity_weight_to_edges(domain, network_name='default_network', edge_weight_name='new weight', node_features=None, similarity_function=None, feature_distance_metric=None)#

Adds edge weight to all connected nodes that is valued as a similarity of node features. Node features can be provided as a label in the domain or as an array of values representing features for each node and are compared using a similarity function.

Parameters:
domainobject

A muspan domain object.

network_namestr, optional

The name of a network stored in the muspan domain object, defaults to ‘default_network’.

edge_weight_namestr, optional

Name given to new edge weights, defaults to ‘new weight’.

node_featuresstr or array-like, optional

A name of a label existing in the domain or an array of values representing features for each node, note n x d where n is the number of nodes and d is the dimension of node feature. If array is provided, it is assumed that array features are ordered corresponding to node order in network. defaults to None.

similarity_functioncallable, optional

A function that takes a feature distance and returns a similarity value, defaults to None.

feature_distance_metricstr, optional

The metric used to calculate the distance between features, defaults to ‘Euclidean’.

Raises:
RuntimeError

If the network name is not in the list of generated networks. If the node feature label is not in the list of labels. If the node feature vector has a different length than the number of nodes in the network. If the similarity function provided is not callable.