Héctor Urbina | 1 Jun 2012 01:45
Picon

how to use a python object saved in a graph property map

Hello,

I have the following code:

sortedEdges = []
g = Graph()
g.graph_properties["sortedEdges"] =
self._graph.new_graph_property("object", sortedEdges)

then I fill the sortedEdges list with the appropriate values and
return g. Now, how can I get the list of sorted edges from g? I'm also
saving a dictionary that uses the names of the vertices as keys and
the graph vertices as values in a internal graph property map; so, in
general, I want to learn how to use any python object after it is
saved as graph_property

Thanks,

--

-- 
Héctor Urbina S.
Ingeniero en Bioinformática
Fono: 82049138
Héctor Urbina | 1 Jun 2012 23:32
Picon

shortest distance in filtered graph doesn't work properly

Hello,

I'm using a graph filtered with the minimum spanning tree and
calculating the shortest distance for all the vertices.

when capturing the array of distances for the vertex with index 0 it gives me:

>>> dist1
array([         0, 2147483647, 2147483647, 2147483647, 2147483647,
       2147483647, 2147483647, 2147483647, 2147483647, 2147483647,
       2147483647, 2147483647, 2147483647, 2147483647, 2147483647,
       2147483647, 2147483647, 2147483647, 2147483647, 2147483647,
       2147483647, 2147483647, 2147483647, 2147483647, 2147483647,
       2147483647, 2147483647, 2147483647, 2147483647, 2147483647,
       2147483647, 2147483647, 2147483647, 2147483647, 2147483647,
       2147483647,          1, 2147483647, 2147483647, 2147483647,
       2147483647, 2147483647, 2147483647, 2147483647, 2147483647,
       2147483647, 2147483647, 2147483647, 2147483647, 2147483647,
       2147483647, 2147483647, 2147483647, 2147483647, 2147483647,
       2147483647, 2147483647, 2147483647, 2147483647, 2147483647,
       2147483647, 2147483647, 2147483647, 2147483647, 2147483647,
       2147483647, 2147483647,          1, 2147483647, 2147483647,
       2147483647, 2147483647, 2147483647, 2147483647, 2147483647,
       2147483647, 2147483647, 2147483647, 2147483647, 2147483647,
       2147483647, 2147483647, 2147483647, 2147483647, 2147483647,
       2147483647, 2147483647, 2147483647, 2147483647, 2147483647,
       2147483647, 2147483647, 2147483647, 2147483647, 2147483647,
       2147483647, 2147483647, 2147483647, 2147483647, 2147483647,
       2147483647, 2147483647, 2147483647, 2147483647, 2147483647,
       2147483647, 2147483647, 2147483647, 2147483647, 2147483647,
(Continue reading)

shakira | 2 Jun 2012 01:58
Picon
Favicon

warning when importing graph_tool.all

Hi, all

I install graph tool and when I passed the following command I am having the
above warning message, what is that? I am using ipython

In [1]: from graph_tool.all import *
/usr/lib/python2.7/dist-packages/gobject/constants.py:24: Warning:
g_boxed_type_register_static: assertion `g_type_from_name (name) == 0'
failed
  import gobject._gobject

Cheers

Shakira

--
View this message in context: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/warning-when-importing-graph-tool-all-tp4024710.html
Sent from the Main discussion list for the graph-tool project mailing list archive at Nabble.com.
Tiago de Paula Peixoto | 4 Jun 2012 00:37
Picon
Gravatar

Re: max flow min cut

Hi Bernardo,

On 05/29/2012 06:47 PM, BWIND wrote:
> hi, I'm relatively new to Python but i managed to get the build the
> graph and attach the capacities to the edges and got some results from
> the Maxflow algorithm. I what to used to implement the min cut and
> separate the graph in two. Did anybody tried this?

Knowing the max flow allows one to know automatically the _value_ of
minimum cut, but not the actual edges in the cut. In order to obtain the
min-cut from s to t, you have to do a slightly larger amount of work:
Just follow all vertices which are reachable from s via edges with
nonzero residual capacity. These form the s-side of the cut set.

Cheers,
Tiago

--

-- 
Tiago de Paula Peixoto <tiago <at> skewed.de>

_______________________________________________
graph-tool mailing list
graph-tool <at> skewed.de
http://lists.skewed.de/mailman/listinfo/graph-tool
Tiago de Paula Peixoto | 4 Jun 2012 00:40
Picon
Gravatar

Re: how to use a python object saved in a graph property map

On 06/01/2012 01:45 AM, Héctor Urbina wrote:
> I have the following code:
> 
> sortedEdges = []
> g = Graph()
> g.graph_properties["sortedEdges"] =
> self._graph.new_graph_property("object", sortedEdges)
> 
> then I fill the sortedEdges list with the appropriate values and
> return g. Now, how can I get the list of sorted edges from g? I'm also
> saving a dictionary that uses the names of the vertices as keys and
> the graph vertices as values in a internal graph property map; so, in
> general, I want to learn how to use any python object after it is
> saved as graph_property

The syntax for graph properties is the same as for vertex or edge
properties, i.e. you use the graph itself as a key. In your case it would be:

   g.graph_properties["sortedEdges"][g].append("foo")

This would append the value "foo" to your list.

Cheers,
Tiago

--
Tiago de Paula Peixoto <tiago <at> skewed.de>

(Continue reading)

Tiago de Paula Peixoto | 4 Jun 2012 00:42
Picon
Gravatar

Re: shortest distance in filtered graph doesn't work properly

On 06/01/2012 11:32 PM, Héctor Urbina wrote:
> Hello,
> 
> I'm using a graph filtered with the minimum spanning tree and
> calculating the shortest distance for all the vertices.
> 
> when capturing the array of distances for the vertex with index 0 it gives me:

[...]

> as if the algorithm were checking for a direct edge between each pair
> of vertices instead of searching for the shortest path and giving the
> appropriate distance.

Are you sure your graph is undirected?

Please provide a complete example so I can understand what is going on.

Cheers,
Tiago

--

-- 
Tiago de Paula Peixoto <tiago <at> skewed.de>

_______________________________________________
graph-tool mailing list
graph-tool <at> skewed.de
http://lists.skewed.de/mailman/listinfo/graph-tool
(Continue reading)

Tiago de Paula Peixoto | 4 Jun 2012 00:45
Picon
Gravatar

Re: warning when importing graph_tool.all

On 06/02/2012 01:58 AM, shakira wrote:
> Hi, all
> 
> I install graph tool and when I passed the following command I am having the
> above warning message, what is that? I am using ipython
> 
> In [1]: from graph_tool.all import *
> /usr/lib/python2.7/dist-packages/gobject/constants.py:24: Warning:
> g_boxed_type_register_static: assertion `g_type_from_name (name) == 0'
> failed
>   import gobject._gobject

This is just a harmless warning emitted by the gobject bindings (not
part of graph-tool). You can safely ignore it. However, if it annoys
you, you should submit a bug to the gnome/gtk developers.

Cheers,
Tiago

--

-- 
Tiago de Paula Peixoto <tiago <at> skewed.de>

_______________________________________________
graph-tool mailing list
graph-tool <at> skewed.de
http://lists.skewed.de/mailman/listinfo/graph-tool
jarino | 4 Jun 2012 08:48
Picon

Vertex variable name from a string

Hi,

I am wondering: is it possible to generate a vertex variable name from a
string. 

Let me explain: I need to read a set of vertices from a csv file, and a set
of arcs from another file. My vertices have names of the form XYZ, and my
arcs then indicate whether there is a connection between XYZ and, say, ABC.

Of course, I could define a property "name", assign it to the vertex, then
find the indices of the origin and end vertices when I browsing my
connection file.

But I am wondering.. From the examples, I would like to do something like

v1 = g.add_vertex()
v2 = g.add_vertex()
e = g.add_edge(v1, v2)

but where v1, v2, etc., would be replaced by vertexName[i] (in a loop).
Probably it is my incompetence with python, but I don't seem to be able to
do that. A call to 

for i in range(1, len(vertexName)):
    vertexName[i] = g.add_vertex()

does not give an error. But when I try to assign an edge using the "same"
method,

for i in range(1, len(listVertices)):
(Continue reading)

Tiago de Paula Peixoto | 4 Jun 2012 11:33
Picon
Gravatar

Re: Vertex variable name from a string

On 06/04/2012 08:48 AM, jarino wrote:
> Hi,
> 
> I am wondering: is it possible to generate a vertex variable name from a
> string. 
> 
> Let me explain: I need to read a set of vertices from a csv file, and a set
> of arcs from another file. My vertices have names of the form XYZ, and my
> arcs then indicate whether there is a connection between XYZ and, say, ABC.
> 
> Of course, I could define a property "name", assign it to the vertex, then
> find the indices of the origin and end vertices when I browsing my
> connection file.
> 
> But I am wondering.. From the examples, I would like to do something like
> 
> v1 = g.add_vertex()
> v2 = g.add_vertex()
> e = g.add_edge(v1, v2)
> 
> but where v1, v2, etc., would be replaced by vertexName[i] (in a loop).
> Probably it is my incompetence with python, but I don't seem to be able to
> do that. A call to 
> 
> for i in range(1, len(vertexName)):
>     vertexName[i] = g.add_vertex()
> 
> does not give an error. But when I try to assign an edge using the "same"
> method,
> 
(Continue reading)

Héctor Urbina | 4 Jun 2012 22:52
Picon

Pickling of "graph_tool.libgraph_tool_core.Edge" instances is not enabled

Hello,

I got this error when trying to save a graph to a file:

Traceback (most recent call last):
  File "/usr/local/bin/graphanalyze.py", line 123, in <module>
    network.save(outFN)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/graph_tool/__init__.py",
line 1443, in save
    self.__graph.WriteToFile(file_name, None, fmt, props)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/graph_tool/io.py",
line 62, in pickler
    pickle.dump(obj, sstream, -1)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py",
line 1370, in dump
    Pickler(file, protocol).dump(obj)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py",
line 224, in dump
    self.save(obj)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py",
line 286, in save
    f(self, obj) # Call unbound method with explicit self
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py",
line 600, in save_list
    self._batch_appends(iter(obj))
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py",
line 633, in _batch_appends
    save(x)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py",
line 286, in save
(Continue reading)


Gmane