1 图类型创建
import networkx as nx
# 无向图
G = nx.Graph()
# 有向图
DG = nx.DiGraph()
# 多重图
MG = nx.MultiGraph()
# 多重有向图
MDG = nx.MultiDiGraph()
2025/12/25大约 3 分钟
import networkx as nx
# 无向图
G = nx.Graph()
# 有向图
DG = nx.DiGraph()
# 多重图
MG = nx.MultiGraph()
# 多重有向图
MDG = nx.MultiDiGraph()
以graphml文件加载到networkx为例,文件基本信息:
<key id="d5" for="edge" attr.name="keywords" attr.type="string"/>
<key id="d4" for="edge" attr.name="description" attr.type="string"/>
<key id="d3" for="edge" attr.name="weight" attr.type="double"/>
<key id="d2" for="node" attr.name="source_id" attr.type="string"/>
<key id="d1" for="node" attr.name="description" attr.type="string"/>
<key id="d0" for="node" attr.name="entity_type" attr.type="string"/>
<graph edgedefault="directed">