1. Creating a graph
Create an empty graph with no nodes and no edges.
import networkx as nx
G = nx.Graph()
1
2
2
By definition, a Graph
(opens new window) is a collection of nodes (vertices) along with identified pairs of nodes (called edges, links, etc). In NetworkX, nodes can be any hashable object e.g., a text string, an image, an XML object, another Graph, a customized node object, etc.
提示
Python’s None
object should not be used as a node as it determines whether optional function arguments have been assigned in many functions.
编辑 (opens new window)
上次更新: 2021/02/16, 02:45:37