I have a list of nodes (Nodes), and a list of edges (Edges). Some nodes are isolated. I want to create a graph that includes all nodes, regardless whether the node is connected or isolated. I can think of two methods to create the graph.
Method 1:
g=ig.Graph.TupleList( Edges , directed=False)
for node in Nodes:
if node not in g.vs["name"]:
g.add_vertex(name=node)
Method 2:
g=ig.Graph()
add_vertices(g, Nodes)
add_edges(g, Edges )
My question is which method is better? I don’t want to create unnecessary objects because the graph is very large, and I need to perform calculations on this graph.