Library import is missing topology section

Conda list reports graph-tool version 2.92
Operating system is Mac 15.3.2

Code:

import graph_tool as gt
dir(gt)

Returns:

['ArgumentError',
 'Edge',
 'EdgeBase',
 'EdgePropertyMap',
 'Graph',
 'GraphPropertyMap',
 'GraphView',
 'InternalPropertyDict',
 'PropertyArray',
 'PropertyDict',
 'PropertyMap',
 'Vector_bool',
 'Vector_cdouble',
 'Vector_double',
 'Vector_int16_t',
 'Vector_int32_t',
 'Vector_int64_t',
 'Vector_long_double',
 'Vector_size_t',
 'Vector_string',
 'Vertex',
 'VertexBase',
 'VertexPropertyMap',
 '__URL__',
 '__all__',
 '__author__',
 '__builtins__',
 '__cached__',
 '__copyright__',
 '__doc__',
 '__file__',
 '__license__',
 '__loader__',
 '__name__',
 '__package__',
 '__path__',
 '__spec__',
 '__version__',
 '_all_edges',
 '_all_neighbors',
 '_check_prop_scalar',
 '_check_prop_vector',
 '_check_prop_writable',
 '_converter',
 '_copy_func',
 '_degree',
 '_edge_doc',
 '_edge_iter',
 '_edge_repr',
 '_get_array_view',
 '_get_null_vertex',
 '_get_rng',
 '_gt_type',
 '_in_degree',
 '_in_neighbors',
 '_limit_args',
 '_out_degree',
 '_out_neighbors',
 '_parallel',
 '_prop',
 '_python_type',
 '_require',
 '_set_array_view',
 '_type_alias',
 '_v_eq',
 '_v_ge',
 '_v_gt',
 '_v_le',
 '_v_lt',
 '_v_ne',
 '_vertex_doc',
 '_vertex_repr',
 '_vt_copy',
 '_vt_getstate',
 '_vt_init',
 '_vt_setstate',
 'bz2',
 'collections',
 'contextlib',
 'contextmanager',
 'copy',
 'csv',
 'decorators',
 'dl_import',
 'edge_endpoint_property',
 'graph_tool',
 'group_vector_property',
 'gt_io',
 'gzip',
 'incident_edges_op',
 'infect_vertex_property',
 'io',
 'itertools',
 'libcore',
 'libgraph_tool_core',
 'load_graph',
 'load_graph_from_csv',
 'lzma',
 'map_property_values',
 'new_edge_property',
 'new_graph_property',
 'new_vertex_property',
 'numpy',
 'openmp',
 'openmp_context',
 'openmp_enabled',
 'openmp_get_num_threads',
 'openmp_get_schedule',
 'openmp_get_thresh',
 'openmp_set_num_threads',
 'openmp_set_schedule',
 'openmp_set_thresh',
 'os',
 'perfect_prop_hash',
 're',
 'scipy',
 'seed_rng',
 'show_config',
 'sys',
 'terminal_size',
 'textwrap',
 'threading',
 'ungroup_vector_property',
 'value_types',
 'vector_types',
 'vt',
 'weakref',
 'zstandard']

I’m trying to run shortest_path under the topology section, and as you can see the topology attribute is missing. I am able to find the shortest_path function if I run “from graph_tool.all import *”, but then the results from shortest_path is wrong (it returns empty paths for a fully connected biological network dataset).

HOWEVER, I was able to randomly somehow “import graph_tool as gt” just once with the topology section and ran it on a start/end path that used to return an incorrect empty path now returns an actual correct path.

So all it’ll take for me to get this to work is getting the import to work, shortening a currently month long network analysis to day/s.

I’ve also tried the dumb approach of creating a new environment, installing just graph-tool on it, importing it, and still I’m missing the topology section.

Any idea why my import is weird? Thank you

#UPDATE
Running:

from graph_tool.all import *
import graph_tool as gt
dir(gt)

Returns:

['ArgumentError',
 'Edge',
 'EdgeBase',
 'EdgePropertyMap',
 'Graph',
 'GraphPropertyMap',
 'GraphView',
 'InternalPropertyDict',
 'PropertyArray',
 'PropertyDict',
 'PropertyMap',
 'Vector_bool',
 'Vector_cdouble',
 'Vector_double',
 'Vector_int16_t',
 'Vector_int32_t',
 'Vector_int64_t',
 'Vector_long_double',
 'Vector_size_t',
 'Vector_string',
 'Vertex',
 'VertexBase',
 'VertexPropertyMap',
 '__URL__',
 '__all__',
 '__author__',
 '__builtins__',
 '__cached__',
 '__copyright__',
 '__doc__',
 '__file__',
 '__license__',
 '__loader__',
 '__name__',
 '__package__',
 '__path__',
 '__spec__',
 '__version__',
 '_all_edges',
 '_all_neighbors',
 '_check_prop_scalar',
 '_check_prop_vector',
 '_check_prop_writable',
 '_converter',
 '_copy_func',
 '_degree',
 '_edge_doc',
 '_edge_iter',
 '_edge_repr',
 '_get_array_view',
 '_get_null_vertex',
 '_get_rng',
 '_gt_type',
 '_in_degree',
 '_in_neighbors',
 '_limit_args',
 '_out_degree',
 '_out_neighbors',
 '_parallel',
 '_prop',
 '_python_type',
 '_require',
 '_set_array_view',
 '_type_alias',
 '_v_eq',
 '_v_ge',
 '_v_gt',
 '_v_le',
 '_v_lt',
 '_v_ne',
 '_vertex_doc',
 '_vertex_repr',
 '_vt_copy',
 '_vt_getstate',
 '_vt_init',
 '_vt_setstate',
 'all',
 'bz2',
 'centrality',
 'clustering',
 'collection',
 'collections',
 'contextlib',
 'contextmanager',
 'copy',
 'correlations',
 'csv',
 'decorators',
 'dl_import',
 'draw',
 'dynamics',
 'edge_endpoint_property',
 'flow',
 'generation',
 'graph_tool',
 'group_vector_property',
 'gt_io',
 'gzip',
 'incident_edges_op',
 'infect_vertex_property',
 'inference',
 'io',
 'itertools',
 'libcore',
 'libgraph_tool_core',
 'load_graph',
 'load_graph_from_csv',
 'lzma',
 'map_property_values',
 'new_edge_property',
 'new_graph_property',
 'new_vertex_property',
 'numpy',
 'openmp',
 'openmp_context',
 'openmp_enabled',
 'openmp_get_num_threads',
 'openmp_get_schedule',
 'openmp_get_thresh',
 'openmp_set_num_threads',
 'openmp_set_schedule',
 'openmp_set_thresh',
 'os',
 'perfect_prop_hash',
 're',
 'scipy',
 'search',
 'seed_rng',
 'show_config',
 'spectral',
 'stats',
 'sys',
 'terminal_size',
 'textwrap',
 'threading',
 'topology',
 'ungroup_vector_property',
 'util',
 'value_types',
 'vector_types',
 'vt',
 'weakref',
 'zstandard']
Selection deleted

But now the “gt.topology.shortest_path” returns an empty path when it used to return an actual path. I think the issue is with the library import, this is really strange behavior.

*Oh and it does return actual paths for some start/end points, even in the broken shortest_path function.
*And I tried installing graph_tool=2.88 and 2.45 still same issue.
*And I tried installing graph_tool on fresh version of ubuntu and it has the same issue.

#UPDATE
I used:
from graph_tool import Graph, topology

and it loaded the code, but I still get empty paths for a fully connected network. Is this import behavior the default or is there really something going wrong?

There’s nothing “strange”. As is explained clearly in the documentation you can import all the submodules with

from graph_tool.all import *

Or the individual submodules with

from graph_tool.topology import *

This is how it’s supposed to work.

Regarding the alleged issue with shortest_path(), you need to provide a minimal working example that shows the problem.

Sorry I didn’t read through the documentation closely, it was just my first time ever encountering .all usage when importing a library in years of programming, which is why it seemed strange.

Thank for your the response