Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Subgraph Drawing

Reply
Thread Tools

Subgraph Drawing

 
 
subhabangalore@gmail.com
Guest
Posts: n/a
 
      01-13-2013
Dear Group,

I have two questions, if I take a subseries of the matrix as in eigenvalue here,
provided I have one graph of the full form in G, how may I show it, as if I do the nx.draw(G) it takes only the original graph.

>>> import numpy
>>> import networkx as nx
>>> import matplotlib.pyplot as plt
>>> G=nx.Graph()
>>> G.add_edges_from([(1,2),(1,3),(1,3),(1,4),(1,5),(1,6),(1,7),(1,])
>>> L =nx.laplacian(G)
>>> print L

[[ 7. -1. -1. -1. -1. -1. -1. -1.]
[-1. 1. 0. 0. 0. 0. 0. 0.]
[-1. 0. 1. 0. 0. 0. 0. 0.]
[-1. 0. 0. 1. 0. 0. 0. 0.]
[-1. 0. 0. 0. 1. 0. 0. 0.]
[-1. 0. 0. 0. 0. 1. 0. 0.]
[-1. 0. 0. 0. 0. 0. 1. 0.]
[-1. 0. 0. 0. 0. 0. 0. 1.]]
>>> print numpy.linalg.eigvals(L)

[ 8.00000000e+00 2.22044605e-16 1.00000000e+00 1.00000000e+00
1.00000000e+00 1.00000000e+00 1.00000000e+00 1.00000000e+00]

for more than 1000 nodes it is coming too slow on Windows 7 machine with 3GB RAM.

If any one of the learned members can help.

Apology for any indentation error etc.

Thanking all in Advance,

Regards,
Subhabrata Banerjee.
 
Reply With Quote
 
 
 
 
Oscar Benjamin
Guest
Posts: n/a
 
      01-13-2013
On 13 January 2013 20:05, <(E-Mail Removed)> wrote:
> Dear Group,
>
> I have two questions, if I take a subseries of the matrix as in eigenvalue here,
> provided I have one graph of the full form in G, how may I show it, as if I do the nx.draw(G) it takes only the original graph.


I'm sorry, but I really don't understand what you mean. When you say
"subseries" do you mean "subgraph"? Or do you mean a subset of the
eigenvalues?

It would be good if you could give a simple example of what you mean
using code and showing the expected/desired output.

>
>>>> import numpy
>>>> import networkx as nx
>>>> import matplotlib.pyplot as plt
>>>> G=nx.Graph()
>>>> G.add_edges_from([(1,2),(1,3),(1,3),(1,4),(1,5),(1,6),(1,7),(1,])
>>>> L =nx.laplacian(G)
>>>> print L

> [[ 7. -1. -1. -1. -1. -1. -1. -1.]
> [-1. 1. 0. 0. 0. 0. 0. 0.]
> [-1. 0. 1. 0. 0. 0. 0. 0.]
> [-1. 0. 0. 1. 0. 0. 0. 0.]
> [-1. 0. 0. 0. 1. 0. 0. 0.]
> [-1. 0. 0. 0. 0. 1. 0. 0.]
> [-1. 0. 0. 0. 0. 0. 1. 0.]
> [-1. 0. 0. 0. 0. 0. 0. 1.]]
>>>> print numpy.linalg.eigvals(L)

> [ 8.00000000e+00 2.22044605e-16 1.00000000e+00 1.00000000e+00
> 1.00000000e+00 1.00000000e+00 1.00000000e+00 1.00000000e+00]
>
> for more than 1000 nodes it is coming too slow on Windows 7 machine with 3GB RAM.


What is too slow?


Oscar
 
Reply With Quote
 
 
 
 
Steven D'Aprano
Guest
Posts: n/a
 
      01-14-2013
On Sun, 13 Jan 2013 12:05:54 -0800, subhabangalore wrote:

> Dear Group,
>
> I have two questions, if I take a subseries of the matrix as in
> eigenvalue here, provided I have one graph of the full form in G, how
> may I show it, as if I do the nx.draw(G) it takes only the original
> graph.


Is this what you mean? If not, you will have to explain your question
better.


L = = nx.laplacian(G)
E = numpy.linalg.eigvals(L)
nx.draw(E)


> >>> print numpy.linalg.eigvals(L)

> [ 8.00000000e+00 2.22044605e-16 1.00000000e+00 1.00000000e+00
> 1.00000000e+00 1.00000000e+00 1.00000000e+00 1.00000000e+00]
> for more than 1000 nodes it is coming too slow on Windows 7 machine with
> 3GB RAM.


Get a faster machine. Or use fewer nodes. Or be patient and wait.

Solving a graph problem with 1000 nodes is a fairly big problem for a
desktop PC. It will take time. Calculations don't just happen instantly,
the more work you have to do the longer they take.

The last alternative is to ask on a specialist numpy list. But I expect
they will probably tell you the same thing.


--
Steven
 
Reply With Quote
 
subhabangalore@gmail.com
Guest
Posts: n/a
 
      01-14-2013
On Monday, January 14, 2013 6:05:49 AM UTC+5:30, Steven D'Aprano wrote:
> On Sun, 13 Jan 2013 12:05:54 -0800, subhabangalore wrote:
>
>
>
> > Dear Group,

>
> >

>
> > I have two questions, if I take a subseries of the matrix as in

>
> > eigenvalue here, provided I have one graph of the full form in G, how

>
> > may I show it, as if I do the nx.draw(G) it takes only the original

>
> > graph.

>
>
>
> Is this what you mean? If not, you will have to explain your question
>
> better.
>
>
>
>
>
> L = = nx.laplacian(G)
>
> E = numpy.linalg.eigvals(L)
>
> nx.draw(E)
>
>
>
>
>
> > >>> print numpy.linalg.eigvals(L)

>
> > [ 8.00000000e+00 2.22044605e-16 1.00000000e+00 1.00000000e+00

>
> > 1.00000000e+00 1.00000000e+00 1.00000000e+00 1.00000000e+00]

>
> > for more than 1000 nodes it is coming too slow on Windows 7 machine with

>
> > 3GB RAM.

>
>
>
> Get a faster machine. Or use fewer nodes. Or be patient and wait.
>
>
>
> Solving a graph problem with 1000 nodes is a fairly big problem for a
>
> desktop PC. It will take time. Calculations don't just happen instantly,
>
> the more work you have to do the longer they take.
>
>
>
> The last alternative is to ask on a specialist numpy list. But I expect
>
> they will probably tell you the same thing.
>
>
>
>
>
> --
>
> Steven


Dear Steven,

Thank you for your kind effort. You got the problem right. But it is giving following error,
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
nx.draw(E)
File "C:\Python27\lib\site-packages\networkx\drawing\nx_pylab.py", line 138, in draw
draw_networkx(G,pos=pos,ax=ax,**kwds)
File "C:\Python27\lib\site-packages\networkx\drawing\nx_pylab.py", line 267, in draw_networkx
pos=nx.drawing.spring_layout(G) # default to spring layout
File "C:\Python27\lib\site-packages\networkx\drawing\layout.py", line 241, in fruchterman_reingold_layout
A=nx.to_numpy_matrix(G,weight=weight)
File "C:\Python27\lib\site-packages\networkx\convert.py", line 492, in to_numpy_matrix
nodelist = G.nodes()
AttributeError: 'numpy.ndarray' object has no attribute 'nodes'
>>>


there are other solution of converting back the matrix to graph should I try that?

Regards,
Subhabrata.
 
Reply With Quote
 
Steven D'Aprano
Guest
Posts: n/a
 
      01-14-2013
On Sun, 13 Jan 2013 20:01:21 -0800, subhabangalore wrote:

> there are other solution of converting back the matrix to graph should I
> try that?


Yes.

--
Steven
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Guide to the standard library? Library for drawing in GUIs?drawing inbrowsers? defn noob Java 1 06-28-2008 02:50 AM
funny drawing software:ScreenPen,drawing directly on screen! yyzzbb@sina.com Digital Photography 0 02-04-2006 12:31 AM
System.Drawing For Drawing Text Images jjbutera@hotmail.com ASP .Net 1 01-09-2006 09:55 PM
HIS Radeon X700 Pro IceQ Turbo drawing Silverstrand Front Page News 6 07-10-2005 08:55 AM
How to Serialize System.Drawing.Pen Sergio Dinis ASP .Net 1 10-03-2003 03:40 AM



Advertisments