evansyangs evansyangs
首页
分类
标签
归档
GitHub (opens new window)

Evan Yang

摸鱼小能手
首页
分类
标签
归档
GitHub (opens new window)
  • NetworkX Learning Notes
  • 1. Creating a graph
  • 2. Nodes
  • 3. Edges
  • 4. What to use as nodes and edges
  • 5. Accessing edges and neighbors
  • 6. Adding attributes to graphs, nodes, and edges
  • 7. Analyzing graphs
  • 8. Directed graphs
  • 9. Drawing graphs
  • 10. Graph generators and graph operations
  • 11. Multigraphs

10. Graph generators and graph operations

In addition to constructing graphs node-by-node or edge-by-edge, they can also be generated by

  1. Applying classic graph operations, such as:
subgraph(G, nbunch)      - induced subgraph view of G on nodes in nbunch
union(G1,G2)             - graph union
disjoint_union(G1,G2)    - graph union assuming all nodes are different
cartesian_product(G1,G2) - return Cartesian product graph
compose(G1,G2)           - combine graphs identifying nodes common to both
complement(G)            - graph complement
create_empty_copy(G)     - return an empty copy of the same graph class
to_undirected(G)         - return an undirected representation of G
to_directed(G)           - return a directed representation of G
1
2
3
4
5
6
7
8
9
  1. Using a call to one of the classic small graphs, e.g.,
petersen = nx.petersen_graph()
tutte = nx.tutte_graph()
maze = nx.sedgewick_maze_graph()
tet = nx.tetrahedral_graph()
1
2
3
4
  1. Using a (constructive) generator for a classic graph, e.g.,
K_5 = nx.complete_graph(5)
K_3_5 = nx.complete_bipartite_graph(3, 5)
barbell = nx.barbell_graph(10, 10)
lollipop = nx.lollipop_graph(10, 20)
1
2
3
4
  1. Using a stochastic graph generator, e.g.,
er = nx.erdos_renyi_graph(100, 0.15)
ws = nx.watts_strogatz_graph(30, 3, 0.1)
ba = nx.barabasi_albert_graph(100, 5)
red = nx.random_lobster(100, 0.9, 0.9)
1
2
3
4
  1. Reading a graph stored in a file using common graph formats, such as edge lists, adjacency lists, GML, GraphML, pickle, LEDA and others.
nx.write_gml(red, "path.to.file")
mygraph = nx.read_gml("path.to.file")
1
2

For details on graph formats see Reading and writing graphs (opens new window) and for graph generator functions see Graph generators (opens new window)

编辑 (opens new window)
#Python
上次更新: 2021/02/16, 02:45:37
9. Drawing graphs
11. Multigraphs

← 9. Drawing graphs 11. Multigraphs→

最近更新
01
Dell7472黑苹果
03-27
02
上手HackMD
04-13
03
Windows Terminal设置
03-14
更多文章>
Theme by Vdoing | Copyright © 2019-2023 Evan Yang
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式