以下 Python 代码:
import networkx as nx
g = nx.DiGraph()
g.add_nodes_from([0, 1])
g.add_edges_from([(0,0), (0,1), (1,0), (1,1)])
nx.write_dot(g, 'g.dot')
gl = nx.line_graph(g)
nx.write_dot(gl, 'gl.dot')
创建以下点格式图:
--- g.dot ---
digraph {
0 -> 0;
0 -> 1;
1 -> 0;
1 -> 1;
}
--- gl.dot ---
strict digraph {
"(0, 1)" -> "(1, 1)";
"(1, 0)" -> "(0, 0)";
"(0, 0)" -> "(0, 1)";
"(1, 1)" -> "(1, 0)";
}
边缘应该:
"(1, 0)" -> "(0, 1)";
"(0, 1)" -> "(1, 0)";
"(0, 0)" -> "(1, 1)";
"(1, 1)" -> "(0, 0)";
在折线图构造中?