Understanding Graph Basics
163
Of course, the
Nodes
and
Edges
are just sitting there now and won’t appear as part
of
AGraph
. You must put them into the container to see them. Use the following
code to add the
Nodes
and
Edges
to
AGraph
.
AGraph.add_nodes_from(Nodes)
AGraph.add_edges_from(Edges)
The NetworkX package contains all sorts of functions you can use to interact with
individual nodes and edges, but the approach shown here is the fastest way to do
things. Even so, you might find that you want to add additional edges later. For
example, you might want to add an edge between 2 and 4, in which case you would
call the
AGraph.add_edge(2, 4)
function.
Do'stlaringiz bilan baham: |