# Which method is better?

**URL:** https://igraph.discourse.group/t/which-method-is-better/2149
**Category:** Usage
**Tags:** Python
**Created:** [4 June 2025 01:27 UTC](https://igraph.discourse.group/t/which-method-is-better/2149 "2025-06-04T01:27:11Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![logion2000](https://avatars.discourse-cdn.com/v4/letter/l/ba8739/32.png) [@logion2000](https://igraph.discourse.group/u/logion2000)
#### Post date: [4 June 2025 01:27 UTC](https://igraph.discourse.group/t/which-method-is-better/2149/1 "2025-06-04T01:27:11Z")

</div>

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:

```python
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:

```python
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.

---

<div class="post-metadata">

### Author: ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)
#### Post date: [8 June 2025 00:51 UTC](https://igraph.discourse.group/t/which-method-is-better/2149/2 "2025-06-08T00:51:11Z")

</div>

Repeated edge or vertex additions will be slow. It’s always better to add an entire batch of edges or vertices at once. Thus Method 2 will be faster.
