Here is code that reproduces the issue for me.

I ran this from ipython in a virtual env.

output:

In [2]: run graphbug.py

27000 27000 {'test_str': <PropertyMap object with key type 'Edge' and value
type 'string', for Graph 0x7f76db44b5d0, at 0x7f76db44b290>, 'test_int':
<PropertyMap object with key type 'Edge' and value type 'int32_t', for
Graph 0x7f76db44b5d0, at 0x7f76db44b550>}

27000 1 {}



On Thu, Jul 17, 2014 at 6:31 PM, ... <[email protected]> wrote:

> In the following, I noticed the data type of the property map changes.
> Any ideas what is going on?
>
> >>> graph_tool.all.__version__
>     '2.2.31 (commit 245d1e2c, Thu Mar 27 11:28:39 2014 +0100)
>
> # having already built my graph
> >>> graph.ep
>
>     {'weight': <PropertyMap object with key type 'Edge' and value type
> 'int32_t', for Graph 0x7f93019b8b90, at 0x7f930058c850>}
>
> >>> graph.ep['weight'].a
>     PropertyArray([28, 18, 32, ...,  7,  8,  8], dtype=int32)
>
> >>> graph.save(graph_file_name)
>
> >>> graph2 = Graph()
>
> >>> graph2.load(graph_file_name)
>
> >>> graph2.ep
>     {'weight': <PropertyMap object with key type 'Edge' and value type
> 'double', for Graph 0x7f93001b7b10, at 0x7f92fc00b190>}
>
> >>> graph2.ep['weight'].a
>     PropertyArray([ 28.,   3.,  18., ...,  11.,   6.,  55.])
>
> Then it gets weirder...
>
> >>> graph.ep['ONE_WAY'] = graph.new_edge_property('string')
>
> >>> for edge in graph.edges():
> ...     graph.ep['ONE_WAY'][edge] = 'TEST!'
>
> >>> graph.ep
>
>     {'ONE_WAY': <PropertyMap object with key type 'Edge' and value type
> 'string', for Graph 0x7f93019b8b90, at 0x7f9327c0dc10>,
>  'weight': <PropertyMap object with key type 'Edge' and value type
> 'int32_t', for Graph 0x7f93019b8b90, at 0x7f930058c850>}
>
> >>> graph.ep['ONE_WAY'][edge]
>     'TEST!'
>
> >>> graph.save(graph_file_name)
>
> >>> graph2 = Graph()
>
> >>> graph2.load(graph_file_name)
>
> >>> graph2.ep
>     {}
>
> >>> graph.num_edges(),graph.num_vertices()
>     (78147, 29870)
>
> >>> graph2.num_edges(),graph2.num_vertices()
>     (1, 29870)
>
>
from graph_tool import Graph, Vertex

graph_file_name = 'debugger.gml'

graph = Graph()

for i in range(27000):
  trash = graph.add_vertex()

last_vert = graph.vertex(graph.num_vertices()-1)

for v in graph.vertices():
  graph.add_edge(v, last_vert)
  last_vert = v

graph.ep['test_int'] = graph.new_edge_property('int32_t')
graph.ep['test_str'] = graph.new_edge_property('string')

edges = graph.edges()
for e in edges:
    graph.ep['test_int'][e] = int(1)
    graph.ep['test_str'][e] = 'ttt' 
print graph.num_vertices(), graph.num_edges(), graph.ep

graph.save(graph_file_name)

graph2 = Graph()

graph2.load(graph_file_name)
 
print graph2.num_vertices(), graph2.num_edges(), graph2.ep
_______________________________________________
graph-tool mailing list
[email protected]
http://lists.skewed.de/mailman/listinfo/graph-tool

Reply via email to