igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] Data structure of network


From: Tamás Nepusz
Subject: Re: [igraph] Data structure of network
Date: Thu, 11 Apr 2013 12:01:41 +0200

> I mean I can traverse and change the label of any node in that network.
This can be done by manipulating the "label" attribute of a node. Nodes can be 
accessed by indexing the "vs" vertex sequence of the graph. E.g.:

graph.vs[1]["label"] = "new label"

Edges can be manipulated similarly by indexing the "es" edge sequence:

graph.es[1]["weight"] = 42

> For example, node 0 has two neighbors 1 and 2. After some time, node 0 may 
> only connect to node 2 or 3. So how can I change this by manipulating the 
> object of network (network = nx.read(net_path))?
Please take a look at the add_edge(), add_edges(), delete_edge() and 
delete_edges() method of the Graph object in the documentation:

http://igraph.sourceforge.net/doc/python/igraph.Graph-class.html#add_edge
http://igraph.sourceforge.net/doc/python/igraph.Graph-class.html#add_edges
http://igraph.sourceforge.net/doc/python/igraph.Graph-class.html#delete_edges

Members of the edge sequence also have a delete() method:

graph.es[1].delete()

By the way, out of curiosity, why do you import the igraph module using the 
alias "nx"? "nx" usually refers to the NetworkX module.

-- 
T.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]