Draw Self-loops in Networkx

2,301 views
Skip to first unread message

satyam

unread,
Sep 11, 2011, 7:31:08 PM9/11/11
to networkx-discuss
Is there a way to draw self-loops in Networkx. I don't see it in the
current version of networkx.

Thanks

Aric Hagberg

unread,
Sep 11, 2011, 8:16:36 PM9/11/11
to networkx...@googlegroups.com
On Sun, Sep 11, 2011 at 5:31 PM, satyam <dira...@gmail.com> wrote:
> Is there a way to draw self-loops in Networkx. I don't see it in the
> current version of networkx.

Unfortunately not. But we are working on improving the drawing and
will add self-loops.

Until then, one approach is to use graphviz (graphviz.org). NetworkX
can write "dot" format files and then you can process them to make the
drawing you like with graphviz.

Aric

satyam mukherjee

unread,
Sep 14, 2011, 11:57:57 AM9/14/11
to networkx...@googlegroups.com
Thanks Aric. I found a way to implement this is R.
> library("igraph")
> dat=read.csv(file.choose(),header=TRUE,row.names=1,check.names=FALSE)
Enter file name: filename1.csv
> m=as.matrix(dat)
> net=graph.adjacency(m,mode="directed",weighted=TRUE,diag=TRUE)
> tkplot(net,vertex.label=V(net)$name,layout=layout.fruchterman.reingold, vertex.label.color="black",edge.color="black",edge.width=E(net)$weight/3, edge.arrow.size=1.5,edge.curved=TRUE)
Loading required package: tcltk
Loading Tcl/Tk interface ... done



Maybe we could create an interface of networkx with R and plot the self loops

Thanks
Satyam



--
You received this message because you are subscribed to the Google Groups "networkx-discuss" group.
To post to this group, send email to networkx...@googlegroups.com.
To unsubscribe from this group, send email to networkx-discu...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/networkx-discuss?hl=en.




--
-------------------------------------------
WHEN LIFE GIVES U HUNDRED REASONS TO CRY,SHOW LIFE THAT U HAVE THOUSAND REASONS TO SMILE :-)

satyam mukherjee
224-436-3672 (Mob)
847-491-7238 (Off)

Moritz Beber

unread,
Sep 14, 2011, 7:47:23 PM9/14/11
to networkx...@googlegroups.com
Hi

On Wed, Sep 14, 2011 at 5:57 PM, satyam mukherjee <dira...@gmail.com> wrote:
> Thanks Aric. I found a way to implement this is R.
>> library("igraph")
>> dat=read.csv(file.choose(),header=TRUE,row.names=1,check.names=FALSE)
> Enter file name: filename1.csv
>> m=as.matrix(dat)
>> net=graph.adjacency(m,mode="directed",weighted=TRUE,diag=TRUE)
>> tkplot(net,vertex.label=V(net)$name,layout=layout.fruchterman.reingold,
>> vertex.label.color="black",edge.color="black",edge.width=E(net)$weight/3,
>> edge.arrow.size=1.5,edge.curved=TRUE)
> Loading required package: tcltk
> Loading Tcl/Tk interface ... done
>
>
> Maybe we could create an interface of networkx with R and plot the self
> loops
>

If you really want to do this with R rather than graphviz, look at the
excellent RPy2 package.

Good luck,
Moritz

Reply all
Reply to author
Forward
0 new messages