networkx

NetworkX library add nodes to gml

I have a .gml file with some data. I want to append new entries into the same gml file by the networkx graph library. Somehow I land up over-writing them. ...

list of all paths from source to sink in directed acyclic graph

Can anyone point me to some resources on how to do this? I'm using networkx as my python library. Thanks! ...

TypeError when iterate over DiGraph()

Hii! I want to get the time execution of my function ( test(G) ). when I use Timer I need to write the type of my object : "test(% ?? )" %G which is DiGraph here. How can I do that? from networkx import nx def test(G): for e in G.edges_iter(): print(e) if __name__=='__main__': from timeit import Timer G = nx.DiGrap...

How to draw same nodes with different edge colours correspond to two different graphs?

Hope my question has not asked before. I have two graphs, which nodes are the same in both of them but edges are different. I want to draw both of graphs in one plot. Which means I have the same nodes, but with two different edge colours. But it gives me two different graphs. How could I have them in one graph but with different edge co...

Need help with NetworkX

Currently im faced with the following problem: I have a script that searches through a specific directory that contains documents. Each document is assigned a number within the filename. Within each document are numbers that also represent another document (filename). How can I create a web that shows what documents lead to what? Any h...

add nods and attribute list and KeyError!

Hi! I have nodes with a list of attributes for each called 'times' in my case. I made a simple model like this and I get KeyError'times'. I need my graph save each node with a list of 'times' as an attribute. How can I fix it? import networkx as nx G = nx.DiGraph() for u in range(10): for t in range(5): if G.has_node(u): ...

(NetworkX) [Python] How can I specify an exact output size for my graph?

http://imgur.com/7wiRw.png The above is the output of my current graph. However, I have yet to manage what I am trying to achieve. I need to output my graph in a larger size so that each node/edge can be viewed with ease. Ive tried nx.draw(G, node_size=size), but that only increases the size of the nodes, not the distance between nodes a...

Most elegant way to find node's predecessors with networkX

I'm working on a graphical model project with python using NetworkX. NetworkX provides simple and good functionality using dictionaries: import networkx as nx G = nx.DiGraph() # a directed graph G.add_edge('a', 'b') print G['a'] # prints {'b': {}} print G['b'] # prints {} I want to use directed graphs because I am coding dependencies ...

Networkx: how to draw coloured edges?

Hi, I've built a graph using the following code: G = networkx.Graph() G.add_edges_from([list(e) for e in P + Q + R]) colors = "bgrcmyk" color_map = [colors[i] for i in range(n/2)] # add colors for i in range(len(P)): edge = list(P[i]) G[edge[0]][edge[1]]['edge_color'] = color_map[i] for i in range(len(P)): edge = lis...

NetworkX (Python): how to change edges' weight by designated rule

I have a weighted graph: F=nx.path_graph(10) G=nx.Graph() for (u, v) in F.edges(): G.add_edge(u,v,weight=1) get the nodes list: [(0, 1), (1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8), (8, 9)] I want to change each edge's weight by this rule: remove one node, such as node 5, clearly, edge (4, 5) and (5, 6) will be del...

NetworkX node attribute drawing

Im using networkx for visualization. I see when I use the function draw_networkx_edge_labels I can retrieve the labels for edges. I want to print the attribute on node ( instead of the label).. try everything almost . still stuck. If i have 5 attributes per node, is there anyway I can print a specific attribute on each node ? For exam...