graph_union issue

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

graph_union issue

BleakHeart
Hello,

I am trying to do the union of 3 different geometric_graph.  
This is what I wrote:

from graph_tool.all import *
from gi.repository import Gtk, Gdk
import numpy as np

# M networks with N total vertices
N = 1500
M = 3

G = Graph(directed=False)
for i in range(M):
        points = np.column_stack([np.random.random(N//M) * 100, i * 100 / M
+ np.random.random(N//M) * 100 / M])
        G = graph_union(G, geometric_graph(points, 0.3))

pos = sfdp_layout(G)
totdeg = G.degree_property_map("total")
win = GraphWindow(G, pos, geometry=(1000, 1000), vertex_size=totdeg)
win.connect("delete_event", Gtk.main_quit)
win.show_all()
Gtk.main()

When I try to run this, I get the following error:
in graph_union
intersection = g2.new_vertex_property("int64_t", -1)
AttributeError: 'tuple' object has no attribute 'new_vertex_property'

Actually I have no idea how to solve this error, I used the grap_union
function before in the same way but the graphs type were:
Graph(directed=False) and random_graph().
Does anyone run this error?






--
Sent from: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/
_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool
Reply | Threaded
Open this post in threaded view
|

Re: graph_union issue

Tiago Peixoto
Administrator
Am 23.04.20 um 19:22 schrieb BleakHeart:

> Hello,
>
> I am trying to do the union of 3 different geometric_graph.  
> This is what I wrote:
>
> from graph_tool.all import *
> from gi.repository import Gtk, Gdk
> import numpy as np
>
> # M networks with N total vertices
> N = 1500
> M = 3
>
> G = Graph(directed=False)
> for i in range(M):
>         points = np.column_stack([np.random.random(N//M) * 100, i * 100 / M
> + np.random.random(N//M) * 100 / M])
>         G = graph_union(G, geometric_graph(points, 0.3))
>
> pos = sfdp_layout(G)
> totdeg = G.degree_property_map("total")
> win = GraphWindow(G, pos, geometry=(1000, 1000), vertex_size=totdeg)
> win.connect("delete_event", Gtk.main_quit)
> win.show_all()
> Gtk.main()
>
> When I try to run this, I get the following error:
> in graph_union
> intersection = g2.new_vertex_property("int64_t", -1)
> AttributeError: 'tuple' object has no attribute 'new_vertex_property'
>
> Actually I have no idea how to solve this error, I used the grap_union
> function before in the same way but the graphs type were:
> Graph(directed=False) and random_graph().
> Does anyone run this error?
Please read the documentation carefully. The function geometric_graph()
returns two values: the graph itself, and a property map with the node
positions. You want to pass only the first returned value to graph_union().

Best,
Tiago

--
Tiago de Paula Peixoto <[hidden email]>


_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool

signature.asc (849 bytes) Download Attachment
--
Tiago de Paula Peixoto <tiago@skewed.de>
Reply | Threaded
Open this post in threaded view
|

Re: graph_union issue

BleakHeart
Yeah, right now I've understood the problem and I've solved it. Thank you!!



--
Sent from: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/
_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool