Beginner's trouble with simple graph_tool code snippets

Hi All,
After compilation of 40 Hours on my laptop, I have just begun working with
graph-tool.
I have installed graph-tool-2.9 and my interest lies in finding minimum
spanning tree
of a graph ..so just tried following code

import numpy as np
from graph_tool.all import *
g, pos = triangulation(np.random((500, 2)) * 4, type="delaunay")
tree = min_spanning_tree(g)
graph_draw(g, pos=pos, edge_color=tree, output="min_tree.pdf")

It throws error
"

g, pos = triangulation(np.random((500, 2)) * 4, type="delaunay")
TypeError: 'module' object is not callable
"

When I do,
g, pos = gt.triangulation(np.random((400, 2)) * 10, type="delaunay")
It shows the error

NameError: name 'gt' is not defined

Is gt python alias for graph_tool?

Thanks in advance.

attachment.html (2 KB)

Hi,

This is more of an numpy issue. Try:

numpy.random.random([500,2])

numpy.random is a module which contains a functions called random and
only the latter can be called (obviously).

Best

Soraltan

attachment.html (1.86 KB)

After compilation of 40 Hours on my laptop, I have just begun working
with graph-tool.

If it takes 40 hours to compile, it means that your system is running
out of memory and swapping. If you make sure the compilation has
sufficient memory, it should take far less than that.

I have installed graph-tool-2.9 and my interest lies in finding minimum spanning tree
of a graph ..so just tried following code

import numpy as np
from graph_tool.all import *
g, pos = triangulation(np.random((500, 2)) * 4, type="delaunay")
tree = min_spanning_tree(g)
graph_draw(g, pos=pos, edge_color=tree, output="min_tree.pdf")

It throws error
"

g, pos = triangulation(np.random((500, 2)) * 4, type="delaunay")
TypeError: 'module' object is not callable
"

When I do,
g, pos = gt.triangulation(np.random((400, 2)) * 10, type="delaunay")
It shows the error

NameError: name 'gt' is not defined

Is gt python alias for graph_tool?

This is mentioned in the very beginning of the documentation.

    graph_tool — graph-tool 2.58 documentation

In short:

    The docstring examples assume that graph_tool.all has been imported as gt:

    >>> import graph_tool.all as gt

Best,
Tiago