networkx 2.8.2 Pypi GitHub Homepage
Other Docs
ParametersRaisesReturns
harmonic_function(G, max_iter=30, label_name='label')

Parameters

G : NetworkX Graph
max_iter : int

maximum number of iterations allowed

label_name : string

name of target labels to predict

Raises

NetworkXError

If no nodes in G have attribute :None:None:`label_name`.

Returns

predicted : list

List of length len(G) with the predicted labels for each node.

Node classification by Harmonic function

Examples

>>> from networkx.algorithms import node_classification
... G = nx.path_graph(4)
... G.nodes[0]["label"] = "A"
... G.nodes[3]["label"] = "B"
... G.nodes(data=True) NodeDataView({0: {'label': 'A'}, 1: {}, 2: {}, 3: {'label': 'B'}})
>>> G.edges()
EdgeView([(0, 1), (1, 2), (2, 3)])
>>> predicted = node_classification.harmonic_function(G)
... predicted ['A', 'A', 'B', 'B']
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /networkx/algorithms/node_classification/hmn.py#17
type: <class 'function'>
Commit: