> 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)
> 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().