graph-tool issueshttps://git.skewed.de/count0/graph-tool/-/issues2024-03-21T16:36:04Zhttps://git.skewed.de/count0/graph-tool/-/issues/774get_all_neighbors (and others) cause segmentation fault instead of error when...2024-03-21T16:36:04ZLuca Pion-Tonachiniget_all_neighbors (and others) cause segmentation fault instead of error when called with nonexistant vertexWhen calling `Graph.get_all_neighbors` on a graph instance and passing an index to a non-existent vertex, it causes a segmentation fault where raising a python exception would be more appropriate.
Example leading to segmentation fault:
...When calling `Graph.get_all_neighbors` on a graph instance and passing an index to a non-existent vertex, it causes a segmentation fault where raising a python exception would be more appropriate.
Example leading to segmentation fault:
```python
import graph_tool as gt
g = gt.Graph() # same result if directed=True
g.get_all_edges(0)
```
produces
```
Segmentation fault (core dumped)
```
Curiously, if `Graph.vertex` is called on the instance first, then it no longer prints as if it were segfaulting but perhaps still is.
Example leading to possible silent segmentation fault:
```python
import graph_tool as gt
g = gt.Graph()
print("get first vertex")
g.vertex(0)
print("get first vertex edges")
g.get_all_edges(0)
```
produces
```
get first vertex
Traceback (most recent call last):
File "vargas_island/tests/graph_tool_error.py", line 5, in <module>
g.vertex(0)
File "/usr/lib/python3/dist-packages/graph_tool/__init__.py", line 2000, in vertex
raise ValueError("Invalid vertex index: %d" % int(i))
ValueError: Invalid vertex index: 0
```
Notice the lack of output from `print("get first vertex edges")`, so perhaps `Graph.vertex` raises a python error and then still causing a fault. I also tried replacing `get_all_neighbors` with `get_all_edges` to the same result, so it is likely a more widespread issue.
## Environment
I'm using graph-tool installed through `apt`
```
python3-graph-tool/focal,now 2.59 amd64 [installed]
```
in a docker containers running Ubuntu 20.04:
```
Distributor ID: Ubuntu
Description: Ubuntu 20.04.6 LTS
Release: 20.04
Codename: focal
```
with python 3.8
```
Python 3.8.10
```https://git.skewed.de/count0/graph-tool/-/issues/773Typo in demo documentation for model selection2024-02-01T09:11:00ZFelipe VacaTypo in demo documentation for model selectionThere are two typos in the "Model Selection" demo section that appears in the following link:
https://graph-tool.skewed.de/static/doc/demos/inference/inference.html#model-selection
1) It says:
[...] the particular non-degree-corrected f...There are two typos in the "Model Selection" demo section that appears in the following link:
https://graph-tool.skewed.de/static/doc/demos/inference/inference.html#model-selection
1) It says:
[...] the particular non-degree-corrected fit is around e^{37.9} times more likely than the non-degree corrected one.
It should say:
[...] than the degree corrected one.
2) It says:
Hence, with a posterior odds ratio of \lambda \approx e^{-47} in favor of the non-degree-corrected model [...].
It should say:
[...] in favor of the degree-corrected model [...].https://git.skewed.de/count0/graph-tool/-/issues/772Potential bug in the clustering.motif_significance function2023-11-01T11:49:08ZOgnyan SimeonovPotential bug in the clustering.motif_significance function# Bug report: Potential bug in the clustering.motif_significance function
## Please follow the general troubleshooting steps first:
- [X] Are you running the latest `graph-tool` version?
- [X] Do you observe the problem with the curren...# Bug report: Potential bug in the clustering.motif_significance function
## Please follow the general troubleshooting steps first:
- [X] Are you running the latest `graph-tool` version?
- [X] Do you observe the problem with the current git version?
- [ ] Are you using Macports or Homebrew? If yes, please submit an issue there instead: https://github.com/Homebrew/brew/issues and https://trac.macports.org/newticket
- [ ] Did you compile `graph-tool` manually?
- [ ] If you answered yes above, did you use the exact same compiler to build `graph-tool`, `boost-python` and `Python`?
Report:
I am analyzing the motifs in a network with self-loops. I ran the clustering.motif function which identifies the motifs and the respective counts for each motif. Then, I looked at the clustering.motif_significance function and the full output also includes motifs and counts (along with zscores, sample counts and sample sd).
However, the lengths of the motif arrays produced by the functions are different, even though in the documentation it is written that the two functions produce the same motif output. Additionally, the counts array generated by clustering.motif_significance contains 0 values at the end, but I think those values correspond to motifs in a different part in the motif array (and should probably not be there if the motif occurs 0 times).
There, are also nan values in the zscores array, potentially caused by the self loops.
In the example below, I added a short for loop that checks the isomorphism of the motifs generated by the two functions and at some points the indices of the isomorphic pairs do not coincide.
Your exact graph-tool version: 2.58
Your operating system: MacOS
Python Version: 3.11.6 | packaged by conda-forge
A minimal working example that shows the problem:
```python
from graph_tool import all as gt
gt.seed_rng(42)
g = gt.random_graph(100, lambda: (5,5), self_loops=True)
motifs_1, counts_1 = gt.motifs(g, 3)
motifs_2, zscores, counts_2, s_counts, s_dev = gt.motif_significance(g, 3, self_loops = True, full_output = True)
#Print motif lengths and counts
print(f"Motif_1 array length: {len(motifs_1)}")
print(f"Motif_2 array length: {len(motifs_2)}")
print(counts_1)
print(counts_2)
#Print Z-Scores
print(f"Z-Scores:{zscores}")
#Graph with index 18 is different in the two motif arrays but the count is the same
gt.graph_draw(motifs_1[18], vertex_font_size=12, edge_pen_width=1.5,
output_size=(1000, 1000), vertex_color="black",
edge_font_size=10, edge_text_color="red")
print(counts_1[18])
gt.graph_draw(motifs_2[18], vertex_font_size=12, edge_pen_width=1.5,
output_size=(1000, 1000), vertex_color="black",
edge_font_size=10, edge_text_color="red")
print(counts_2[18])
# Initialize a list to store isomorphic pairs
isomorphic_pairs = []
# Iterate through the graphs in motifs_array1
for index, graph in enumerate(motifs_1):
# Iterate through the graphs in motifs_1
for s_index, s_graph in enumerate(motifs_2):
# Check if the current graph in motifs_array2 is isomorphic to the current graph in motifs_1
if gt.isomorphism(graph, s_graph):
isomorphic_pairs.append((index, s_index))
# Print the isomorphic pairs
if isomorphic_pairs:
for motif_index, s_index in isomorphic_pairs:
print(f"motif_1 index: {motif_index}, motif_2 index: {s_index}")
else:
print("No isomorphic pairs found.")
```https://git.skewed.de/count0/graph-tool/-/issues/771problem with compilation2023-10-27T09:11:26ZJakub Krajniakproblem with compilation# Bug reports:
## Please follow the general troubleshooting steps first:
- [x] Are you running the latest `graph-tool` version?
- [x] Do you observe the problem with the current git version?
- [ ] Are you using Macports or Homebrew? If...# Bug reports:
## Please follow the general troubleshooting steps first:
- [x] Are you running the latest `graph-tool` version?
- [x] Do you observe the problem with the current git version?
- [ ] Are you using Macports or Homebrew? If yes, please submit an issue there instead: https://github.com/Homebrew/brew/issues and https://trac.macports.org/newticket
- [x] Did you compile `graph-tool` manually?
- [x] If you answered yes above, did you use the exact same compiler to build `graph-tool`, `boost-python` and `Python`?
Please replace this section with a brief summary of your issue.
## Do **not** forget to supply the following information:
- [ ] **A _minimal_ and _self-contained_ example that shows the problem.**
- [x] Your operating system. Linux
- [x] The Python version you are using. 3.9
- [x] If you compiled graph-tool manually: Your compiler version, as well as the version of Boost being used. gcc9, boost 1.83
- [ ] If you are reporting a compilation error, please provide the **entire** `./configure` output, as well as the **entire** contents of the `config.log` file and the **entire** compilation output.
Do not forget to add code snippets and error messages using [Markdown](/help/user/markdown.md), i.e.
```
Graph-tool compilation error
src/graph/inference/blockmodel/../support/graph_state.hh:198:13: required from 'static void graph_tool::StateWrap<Factory, TRS>::dispatch(boost::python::api::object&, F&&, bool) [with TS = {boost::any&, boost::any&, boost::any&, boost::checked_vector_property_map<int, boost::adj_edge_index_property_map<long unsigned int> >, boost::checked_vector_property_map<int, boost::typed_identity_property_map<long unsigned int> >, boost::checked_vector_property_map<int, boost::typed_identity_property_map<long unsigned int> >, boost::checked_vector_property_map<int, boost::typed_identity_property_map<long unsigned int> >, boost::checked_vector_property_map<int, boost::typed_identity_property_map<long unsigned int> >, boost::checked_vector_property_map<int, boost::typed_identity_property_map<long unsigned int> >, boost::checked_vector_property_map<int, boost::typed_identity_property_map<long unsigned int> >, boost::checked_vector_property_map<std::vector<double, std::allocator<double> >, boost::typed_identity_property_map<long unsigned int> >, std::vector<double, std::allocator<double> >&, bool, std::vector<int, std::allocator<int> >, std::vector<boost::checked_vector_property_map<double, boost::adj_edge_index_property_map<long unsigned int> >, std::allocator<boost::checked_vector_property_map<double, boost::adj_edge_index_property_map<long unsigned int> > > >, std::vector<boost::checked_vector_property_map<double, boost::adj_edge_index_property_map<long unsigned int> >, std::allocator<boost::checked_vector_property_map<double, boost::adj_edge_index_property_map<long unsigned int> > > >, std::vector<boost::checked_vector_property_map<double, boost::adj_edge_index_property_map<long unsigned int> >, std::allocator<boost::checked_vector_property_map<double, boost::adj_edge_index_property_map<long unsigned int> > > >, std::vector<boost::checked_vector_property_map<double, boost::adj_edge_index_property_map<long unsigned int> >, std::allocator<boost::checked_vector_property_map<double, boost::adj_edge_index_property_map<long unsigned int> > > >, boost::checked_vector_property_map<double, boost::typed_identity_property_map<long unsigned int> >, std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >&, std::vector<double, std::allocator<double> >&, std::vector<double, std::allocator<double> >&, std::vector<double, std::allocator<double> >&}; F = do_gibbs_sweep(boost::python::api::object, boost::python::api::object, rng_t&)::<lambda(auto:207&)>&; Factory = graph_tool::StateFactory<graph_tool::BlockState>; TRS = {graph_tool::detail::all_graph_views, boost::mpl::vector1<std::integral_constant<bool, true> >, boost::mpl::vector2<std::integral_constant<bool, true>, std::integral_constant<bool, false> >, boost::mpl::vector1<std::integral_constant<bool, false> >}]'
src/graph/inference/blockmodel/graph_blockmodel_gibbs.cc:31:1: required from 'static void block_state::dispatch(boost::python::api::object, F&&, bool) [with F = do_gibbs_sweep(boost::python::api::object, boost::python::api::object, rng_t&)::<lambda(auto:207&)>&]'
src/graph/inference/blockmodel/graph_blockmodel_gibbs.cc:55:49: required from here
src/graph/inference/blockmodel/graph_blockmodel_emat.hh:121:12: error: 'graph_tool::EHash<boost::undirected_adaptor<boost::adj_list<long unsigned int> > >::ehash_t' {aka 'class gt_hash_map<long unsigned int, boost::detail::adj_edge_descriptor<long unsigned int>, std::hash<long unsigned int>, std::equal_to<long unsigned int>, std::allocator<std::pair<const long unsigned int, boost::detail::adj_edge_descriptor<long unsigned int> > > >'} has no member named 'min_load_factor'; did you mean 'max_load_factor'?
121 | _h.min_load_factor(.25);
| ~~~^~~~~~~~~~~~~~~
| max_load_factor
make[1]: *** [Makefile:3907: src/graph/inference/blockmodel/graph_blockmodel_gibbs.lo] Error 1
make[1]: Leaving directory '/work/06148/vsc31483/ls6/software/src/graph-tool'
make: *** [Makefile:2067: all] Error 2
```
_You can erase any parts of this template not applicable to your Issue._
Please note we may immediately close your issue without comment if you do not fill out the issue template and provide the requested information.https://git.skewed.de/count0/graph-tool/-/issues/770Error when load_graph_from_csv()2023-10-18T14:32:39ZRongbo WuError when load_graph_from_csv()# Bug reports:
## Please follow the general troubleshooting steps first:
- [-] Are you running the latest `graph-tool` version?
- [-] Do you observe the problem with the current git version?
- [ ] Are you using Macports or Homebrew? If...# Bug reports:
## Please follow the general troubleshooting steps first:
- [-] Are you running the latest `graph-tool` version?
- [-] Do you observe the problem with the current git version?
- [ ] Are you using Macports or Homebrew? If yes, please submit an issue there instead: https://github.com/Homebrew/brew/issues and https://trac.macports.org/newticket
- [ ] Did you compile `graph-tool` manually?
- [ ] If you answered yes above, did you use the exact same compiler to build `graph-tool`, `boost-python` and `Python`?
Please replace this section with a brief summary of your issue.
## Do **not** forget to supply the following information:
- [ ] **A _minimal_ and _self-contained_ example that shows the problem.**
- [ ] When use `gt.load_graph_from_csv(f, directed=True, skip_first=True)`:
``` 3657 eprop_names = list(first_line)
3658 del eprop_names[min(ecols)]
-> 3659 del eprop_names[max(ecols)-1]
3661 for i, p in enumerate(eprops):
3662 if eprop_names is not None:
IndexError: list assignment index out of range
```
It seems it dels column 0 twice?
- [ ] Your operating system.
- [ ] CentOS 8
- [ ] The Python version you are using.
- [ ] 3.10.11
- [ ] If you compiled graph-tool manually: Your compiler version, as well as the version of Boost being used.
- [ ] If you are reporting a compilation error, please provide the **entire** `./configure` output, as well as the **entire** contents of the `config.log` file and the **entire** compilation output.
Do not forget to add code snippets and error messages using [Markdown](/help/user/markdown.md), i.e.
```
Insert your code/shell command/error message here.
```
_You can erase any parts of this template not applicable to your Issue._
Please note we may immediately close your issue without comment if you do not fill out the issue template and provide the requested information.https://git.skewed.de/count0/graph-tool/-/issues/769Build issue with boost 1.832023-09-30T20:04:35ZDavid SeifertBuild issue with boost 1.83I'm trying to bump graph-tool in gentoo, and am getting the following error:
```
In file included from src/graph/graph_io.cc:40:
src/graph/gml.hh: In function 'bool graph_tool::read_gml(std::istream&, Graph&, boost::dynamic_properties&, ...I'm trying to bump graph-tool in gentoo, and am getting the following error:
```
In file included from src/graph/graph_io.cc:40:
src/graph/gml.hh: In function 'bool graph_tool::read_gml(std::istream&, Graph&, boost::dynamic_properties&, const std::unordered_set<std::__cxx11::basic_string<char> >&, const std::unordered_set<std::__cxx11::basic_string<char> >&, const std::unordered_set<std::__cxx11::basic_string<char> >&)':
src/graph/gml.hh:367:5: error: 'u8_to_u32_iterator' was not declared in this scope
367 | u8_to_u32_iterator<spirit::istream_iterator> tbegin(begin), tend(end);
| ^~~~~~~~~~~~~~~~~~
src/graph/gml.hh:367:48: error: expected primary-expression before '>' token
367 | u8_to_u32_iterator<spirit::istream_iterator> tbegin(begin), tend(end);
| ^
src/graph/gml.hh:367:50: error: there are no arguments to 'tbegin' that depend on a template parameter, so a declaration of 'tbegin' must be available [-fpermissive]
367 | u8_to_u32_iterator<spirit::istream_iterator> tbegin(begin), tend(end);
| ^~~~~~
src/graph/gml.hh:367:50: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
src/graph/gml.hh:367:65: error: there are no arguments to 'tend' that depend on a template parameter, so a declaration of 'tend' must be available [-fpermissive]
367 | u8_to_u32_iterator<spirit::istream_iterator> tbegin(begin), tend(end);
| ^~~~
src/graph/gml.hh:370:23: error: 'tbegin' was not declared in this scope; did you mean 'begin'?
370 | parse_grammar(tbegin, tend, g, dp,
| ^~~~~~
| begin
src/graph/gml.hh:370:31: error: 'tend' was not declared in this scope; did you mean 'end'?
370 | parse_grammar(tbegin, tend, g, dp,
| ^~~~
| end
```https://git.skewed.de/count0/graph-tool/-/issues/768segfault by is_planar() function on graph view2023-09-22T18:37:29ZDenis Koshelevsegfault by is_planar() function on graph view# Bug reports:
I was trying to analyze certain graph instances, in particular their connected components isolated. However, in one case while checking planarity I encounter segfault.
System info:
- macOS Monterey 12.5
- Python 3.11.3
...# Bug reports:
I was trying to analyze certain graph instances, in particular their connected components isolated. However, in one case while checking planarity I encounter segfault.
System info:
- macOS Monterey 12.5
- Python 3.11.3
I attach a graph instance itself for the production:
[heuristic_014.gr](/uploads/56896e1cfa6791ec1ff6524e9df1d6c4/heuristic_014.gr)
Here is minimal code for reproducing:
```
import sys
import graph_tool as gt
import graph_tool.topology as topology
def read_graph(file_path):
with open(file_path, 'r') as f:
lines = f.readlines()
vertices, edges = map(int, lines[0].split()[2:])
adj_list = {i: [] for i in range(1, vertices + 1)}
for line in lines[1:]:
if line.strip() and line[0] != 'p':
u, v = map(int, line.split())
adj_list[u].append(v)
adj_list[v].append(u)
return vertices, edges, adj_list
def build_graph_tool_graph(vertices, edges, adj_list):
g = gt.Graph(directed=False)
g.add_vertex(vertices)
edge_list = [(u - 1, v - 1) for u, neighbors in adj_list.items() for v in neighbors if u < v]
g.add_edge_list(edge_list)
return g
def analyze_component(graph, component_filter, component_idx=None):
filtered_graph = gt.GraphView(graph, vfilt=component_filter)
is_planar = topology.is_planar(filtered_graph)
return {
'component': component_idx if component_idx else 'original',
'planarity': is_planar,
}
if __name__ == "__main__":
graph_file = sys.argv[1]
vertices, edges, adj_list = read_graph(graph_file)
graph_tool_graph = build_graph_tool_graph(vertices, edges, adj_list)
comp, hist = topology.label_components(graph_tool_graph)
if len(hist) > 1: # multiple components
results = []
for idx, component in enumerate(hist):
component_filter = comp.a == idx
results.append(analyze_component(graph_tool_graph, component_filter, idx))
else:
results = [analyze_component(graph_tool_graph, None)]
```https://git.skewed.de/count0/graph-tool/-/issues/767'graph_tool' has no attribute 'graph_draw'2023-09-06T07:29:14ZEbrahim Aly'graph_tool' has no attribute 'graph_draw'# Bug reports:
## Please follow the general troubleshooting steps first:
- [ ] Are you running the latest `graph-tool` version?
- [ ] Do you observe the problem with the current git version?
- [ ] Are you using Macports or Homebrew? If...# Bug reports:
## Please follow the general troubleshooting steps first:
- [ ] Are you running the latest `graph-tool` version?
- [ ] Do you observe the problem with the current git version?
- [ ] Are you using Macports or Homebrew? If yes, please submit an issue there instead: https://github.com/Homebrew/brew/issues and https://trac.macports.org/newticket
- [ ] Did you compile `graph-tool` manually?
- [ ] If you answered yes above, did you use the exact same compiler to build `graph-tool`, `boost-python` and `Python`?
Please replace this section with a brief summary of your issue.
## Do **not** forget to supply the following information:
- [ ] **A _minimal_ and _self-contained_ example that shows the problem.**
- [ ] Your operating system.
- [ ] The Python version you are using.
I have installed graph_tool(v 2.58) through conda (python 3.11.4) on macOS 13.5.1,
when I try to run the following code:
```
import graph_tool as gt
g = gt.Graph([('retrieve', 'demonstrate'), ('retrieve', 'play'), ('demonstrate', 'play'), ('play', 'return')],
hashed= True)
gt.graph_draw(g)
```
I get the following error:
`AttributeError: module 'graph_tool' has no attribute 'graph_draw'`
same error occurs when i import using `from graph_tool import *`https://git.skewed.de/count0/graph-tool/-/issues/766Copy a graph_tool.Graph into a new one causes an enormously slowdown2023-09-23T20:52:16ZGerion ECopy a graph_tool.Graph into a new one causes an enormously slowdownIn a program, I have this code snipped:
```py
mapping = graph.new_vp("int64_t", vals=numpy.arange(graph.num_vertices()))
g = Graph(graph, prune=True, vorder=mapping)
```
`graph` is a `graph_tool.GraphView` (based on multiple vertex and e...In a program, I have this code snipped:
```py
mapping = graph.new_vp("int64_t", vals=numpy.arange(graph.num_vertices()))
g = Graph(graph, prune=True, vorder=mapping)
```
`graph` is a `graph_tool.GraphView` (based on multiple vertex and edge filters).
The whole code can be found here: https://github.com/luhsra/ara/blob/soso/ara/steps/create_abbs.py#L147
When I run the (whole) program, it needs around 2s to execute. The program consists at minimum of several thousands of LOC. Now, when I run the program in parallel with a very similar input (especially the mentioned `graph` object is equal, I use `meson test --suite ...` to start the program 3 times in parallel), its runtime increases to ~40s.
After debugging and profiling, I found that replacing the above lines with:
```py
mapping = graph.new_vp("int64_t", vals=numpy.arange(graph.num_vertices()))
g = Graph()
```
reduces that runtime to ~8s.
The profiler says, that 60-80% of the runtime of the program belongs to the native copy operation in `graph-tool/__init__.py` line 1789:
```py
# The actual copying of the graph and property maps
self.__graph = libcore.GraphInterface(gv.__graph, False,
vprops,
eprops,
_prop("v", gv, vorder))
```
The profiling indicates that a lot of time is used for spinning in libgomp (a part of pthreads of gcc) at `gomp_team_barrier_wait_end` and `gomp_simple_barrier_wait`, but this happens _only_ when multiple processes are running in parallel.
I have no clue at all, why another process has some interference here (the processes do not communicate!).
Do you have an idea what might be wrong here?https://git.skewed.de/count0/graph-tool/-/issues/765ImportError from draw after openmp_set_num_threads2023-09-17T18:44:56ZSilmathoronImportError from draw after openmp_set_num_threads```python
>>> import graph_tool
>>> graph_tool.openmp_set_num_threads(1)
>>> from graph_tool.draw import graph_draw
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'graph_draw' from ...```python
>>> import graph_tool
>>> graph_tool.openmp_set_num_threads(1)
>>> from graph_tool.draw import graph_draw
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'graph_draw' from 'graph_tool.draw' (/usr/lib/python3/dist-packages/graph_tool/draw/__init__.py)
```
Obviously import works fine without the call to ``openmp_set_num_threads``.
Tested on Python 3.10.12 with version 2.58 (commit 187fb477, Thu Aug 17 23:44:58 2023 +0200), installed via the PPA on an Ubuntu 22.04 LTS.https://git.skewed.de/count0/graph-tool/-/issues/763[Feature request] Calculate the extended clustering coefficient for a subset ...2023-08-11T13:18:55Zgiacomozonneveld[Feature request] Calculate the extended clustering coefficient for a subset of nodesIt would be great to have an option enabling coefficients computation for a subset of nodes of a graph. This would reduce computation time in scenarios where coefficients are needed only for some nodes of a large graphIt would be great to have an option enabling coefficients computation for a subset of nodes of a graph. This would reduce computation time in scenarios where coefficients are needed only for some nodes of a large graphhttps://git.skewed.de/count0/graph-tool/-/issues/762graph-tool docs2023-08-07T15:50:13ZRolf Sandergraph-tool docsAs already mentioned at https://forum.skewed.de/t/graph-tool-docs/1491, I suggest a few minor bug fixes in the docs:
- In the description of "class GraphWidget" on the webpage https://graph-tool.skewed.de/static/doc/_modules/graph_tool/...As already mentioned at https://forum.skewed.de/t/graph-tool-docs/1491, I suggest a few minor bug fixes in the docs:
- In the description of "class GraphWidget" on the webpage https://graph-tool.skewed.de/static/doc/_modules/graph_tool/draw/gtk_draw.html, highlight_color" is not explained in the docstring.
- On the same web page, the parameter "eprops" in the function
"interactive_window" is described as "Dictionary with the vertex
properties". I guess this should be EDGE properties.
- On
https://graph-tool.skewed.de/static/doc/autosummary/graph_tool.draw.GraphWidget.html,
"pos" is not explained for layout_callback and key_press_callback.https://git.skewed.de/count0/graph-tool/-/issues/761graph-tool 2.57 build fails on macOS Ventura2023-08-17T21:46:12ZStevegraph-tool 2.57 build fails on macOS Ventura# Bug reports:
## Please follow the general troubleshooting steps first:
- [x] Are you running the latest `graph-tool` version?
- [x] Do you observe the problem with the current git version?
- [x] Are you using Macports or Homebrew? If...# Bug reports:
## Please follow the general troubleshooting steps first:
- [x] Are you running the latest `graph-tool` version?
- [x] Do you observe the problem with the current git version?
- [x] Are you using Macports or Homebrew? If yes, please submit an issue there instead: https://github.com/Homebrew/brew/issues and https://trac.macports.org/newticket
- [x] Did you compile `graph-tool` manually?
- [x] If you answered yes above, did you use the exact same compiler to build `graph-tool`, `boost-python` and `Python`?
I'm the `graph-tool` maintainer for MacPorts. `graph-tool` builds fail on macOS Ventura boxes. I tested separately on a Mac Studio with an M2 Ultra, an MBA with an M1, and a Mac Mini x86_64, and see the same issue. The exact same build procedure works for `graph-tool` version 2.46.
The build errors are:
```sh
:info:build In file included from ./src/graph/graph.hh:42:
:info:build ./src/graph/graph_properties.hh:466:19: error: no template named 'unary_function' in namespace 'std'; did you mean '__unary_function'?
:info:build : public std::unary_function<typename IndexMap::key_type, size_t>
:info:build ~~~~~^~~~~~~~~~~~~~
:info:build __unary_function
```
A full log file is attached with `./configure` and other outputs:
[main_py310-graph-tool_x86_64.log.gz](https://git.skewed.de/count0/graph-tool/uploads/48ab835efb1b7d7d9e41d0c547a37382/main_py310-graph-tool_x86_64.log.gz)
Build environment:
macOS 13.4.1 22F770820d arm64
Xcode 14.3.1 14E300c
Python 3.10
The MacPorts build routines are standard based on `graph-tool` build-from-source instructions and have been more-or-less working on `x86_64` boxes for years:
https://github.com/macports/macports-ports/blob/master/python/py-graph-tool/Portfile
## Do **not** forget to supply the following information:
- [x] **A _minimal_ and _self-contained_ example that shows the problem.**
- [x] Your operating system.
- [x] The Python version you are using.
- [x] If you compiled graph-tool manually: Your compiler version, as well as the version of Boost being used.
- [x] If you are reporting a compilation error, please provide the **entire** `./configure` output, as well as the **entire** contents of the `config.log` file and the **entire** compilation output.https://git.skewed.de/count0/graph-tool/-/issues/760Improper quotation encoding in GML files, and other deviations from the spec2023-09-01T13:35:53ZSzabolcs HorvátImproper quotation encoding in GML files, and other deviations from the specgraph-tool's GML writer deviates from the GML spec in several ways, which prevents other software from reading files created by graph-tool. You can download the "technical report" containing the spec here:
https://web.archive.org/web/20...graph-tool's GML writer deviates from the GML spec in several ways, which prevents other software from reading files created by graph-tool. You can download the "technical report" containing the spec here:
https://web.archive.org/web/20190207140002/http://www.fim.uni-passau.de/index.php?id=17297%26L=1
The most problematic behaviour is the escaping of strings. graph-tool uses backslash escaping, but GML requires using `quot;` instead. IPython transcript of an example:
```
In [1]: from graph_tool.all import *
Installed osx event loop hook.
In [2]: g = Graph()
In [3]: g.graph_properties['foo'] = g.new_graph_property('string', 'one "two" three')
In [4]: g.save('test.gml')
```
This results in:
```
graph [
directed 1
foo "one \"two\" three"
]
```
This file won't be read by any of igraph, NetworkX, yEd.
Other issues are visible in the GML version of this graph:
https://networks.skewed.de/net/ceo_club
Namely:
- Property names are not allowed to contain underscores. Both NetworkX and yEd choke on this.
- It is unclear if strings are allowed to contain newlines. NetworkX chokes on this.
igraph doesn't mind either of these two issues. I was the last person to work on igraph's GML reader and my philosophy was to be as lenient during parsing as feasible. So underscores and newlines are no problem. However, interpreting the backslash as an escape character directly conflicts with how other software interprets GML strings, so I decided not to let igraph's parser handle this.https://git.skewed.de/count0/graph-tool/-/issues/759graph_blockmodel_dynamics_cising_glauber_mcmc_h.cc is also missing2023-08-17T21:46:13Zmark-dawngraph_blockmodel_dynamics_cising_glauber_mcmc_h.cc is also missingThank you for the quick fix for [issue#757](https://git.skewed.de/count0/graph-tool/-/issues/757), however I wanted to report that the continous Ising model `CIsingGlauberBlockState` suffers from the same problem, so a `graph_blockmodel_...Thank you for the quick fix for [issue#757](https://git.skewed.de/count0/graph-tool/-/issues/757), however I wanted to report that the continous Ising model `CIsingGlauberBlockState` suffers from the same problem, so a `graph_blockmodel_dynamics_cising_glauber_mcmc_h.cc` file should be added as well.
The minimal example to reproduce is analogous:
```python
# We will first simulate the dynamics with a given network
g = gt.collection.data["dolphins"]
ss = []
for i in range(100):
si_state = gt.CIsingGlauberState(g, beta=.7)
s = [si_state.get_state().copy()]
for j in range(10):
si_state.iterate_sync()
s.append(si_state.get_state().copy())
s = gt.group_vector_property(s)
ss.append(s)
# Prepare the initial state of the reconstruction as an empty graph
u = g.copy()
u.clear_edges()
ss = [u.own_property(s) for s in ss] # time series properties need to be 'owned' by graph u
# Create reconstruction state
rstate = gt.CIsingGlauberBlockState(u, s=ss, beta=.7, nested=False, aE=g.num_edges())
gm = None
bs = []
def collect_marginals(s):
global gm, bs
gm = s.collect_marginal(gm)
bs.append(s.bstate.b.a.copy())
gt.mcmc_equilibrate(rstate, force_niter=1000, mcmc_args=dict(niter=10, xstep=0),
callback=collect_marginals)
```
with error: `AttributeError: module 'graph_tool.inference.libgraph_tool_inference' has no attribute 'mcmc_cising_glauber_sweep_h'`https://git.skewed.de/count0/graph-tool/-/issues/758`minimize_blockmodel_dl` error with numpy 1.25.2023-06-29T14:56:07ZRodrigo Vargas`minimize_blockmodel_dl` error with numpy 1.25.I installed `graph-tool` in a fresh conda environment (python=3.11) via `conda install -c conda-forge graph-tool`. I got an environment with `graph-tool=2.56` and `numpy=1.25.0`. In this environment, execution of
```
from graph_tool.all ...I installed `graph-tool` in a fresh conda environment (python=3.11) via `conda install -c conda-forge graph-tool`. I got an environment with `graph-tool=2.56` and `numpy=1.25.0`. In this environment, execution of
```
from graph_tool.all import *
g = collection.ns["ego_social/facebook_combined"]
state = minimize_blockmodel_dl(g)
```
results in the following error:
```
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/vargonis/miniconda3/envs/langchain/lib/python3.11/site-packages/graph_tool/inference/minimize.py", line 128, in minimize_blockmodel_dl
state = state(g, **state_args)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/vargonis/miniconda3/envs/langchain/lib/python3.11/site-packages/graph_tool/inference/blockmodel.py", line 239, in __init__
B = min(B, self.g.num_vertices())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vargonis/miniconda3/envs/langchain/lib/python3.11/site-packages/numpy/core/fromnumeric.py", line 2953, in min
return _wrapreduction(a, np.minimum, 'min', axis, None, out,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vargonis/miniconda3/envs/langchain/lib/python3.11/site-packages/numpy/core/fromnumeric.py", line 88, in _wrapreduction
return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
numpy.exceptions.AxisError: axis 4039 is out of bounds for array of dimension 0
```
The error goes away if one creates the environment like this: `conda create -c conda-forge -n my_env_name python=3.11 numpy=1.24 graph-tool`.https://git.skewed.de/count0/graph-tool/-/issues/757Using IsingGlauberBlockState inference2023-06-30T11:37:08Zmark-dawnUsing IsingGlauberBlockState inference# Bug reports:
## Please follow the general troubleshooting steps first:
- [x] Are you running the latest `graph-tool` version?
- [ ] Do you observe the problem with the current git version? (haven't tried)
OS is arch linux, but every...# Bug reports:
## Please follow the general troubleshooting steps first:
- [x] Are you running the latest `graph-tool` version?
- [ ] Do you observe the problem with the current git version? (haven't tried)
OS is arch linux, but everything is installed in miniconda using the standard conda-forge repo; python 3.10, last version of grap-tool.
I was trying to use the `IsingGlauberBlockState` class on some time series of a neural network. I used as a base the code shown for the [shown for the Epidemic version on the cookbook](https://graph-tool.skewed.de/static/doc/demos/inference/inference.html#reconstruction-from-dynamics) (which works no problem).
However switching the `EpidemicsBlockState` class for either the continuous or discrete Ising, as in this minimal example:
```python
# We will first simulate the dynamics with a given network
g = gt.collection.data["dolphins"]
ss = []
for i in range(100):
si_state = gt.IsingGlauberState(g, beta=.7)
s = [si_state.get_state().copy()]
for j in range(10):
si_state.iterate_sync()
s.append(si_state.get_state().copy())
# Each time series should be represented as a single vector-valued
# vertex property map with the states for each note at each time.
s = gt.group_vector_property(s)
ss.append(s)
# Prepare the initial state of the reconstruction as an empty graph
u = g.copy()
u.clear_edges()
ss = [u.own_property(s) for s in ss] # time series properties need to be 'owned' by graph u
# Create reconstruction state
rstate = gt.IsingGlauberBlockState(u, s=ss, beta=.7,
nested=False, aE=g.num_edges())
# Now we collect the marginals for exactly 10000 sweeps, at
# intervals of 10 sweeps:
gm = None
bs = []
betas = []
def collect_marginals(s):
global gm, bs
gm = s.collect_marginal(gm)
bs.append(s.bstate.b.a.copy())
betas.append(s.params["beta"])
gt.mcmc_equilibrate(rstate, force_niter=1000, mcmc_args=dict(niter=10, xstep=0),
callback=collect_marginals)
```
results in an error:
`AttributeError: module 'graph_tool.inference.libgraph_tool_inference' has no attribute 'mcmc_ising_glauber_sweep_h'`
The stack trace:
```
File "/lib/python3.10/site-packages/graph_tool/inference/mcmc.py", line 123, in mcmc_equilibrate
delta, nattempts, nmoves = state.multiflip_mcmc_sweep(**mcmc_args)
File "/lib/python3.10/site-packages/graph_tool/inference/uncertain_blockmodel.py", line 216, in multiflip_mcmc_sweep
return self.mcmc_sweep(multiflip=True, **kwargs)
File "/lib/python3.10/site-packages/graph_tool/inference/uncertain_blockmodel.py", line 1320, in mcmc_sweep
return super().mcmc_sweep(r=r, p=p, pstep=p, h=h, hstep=hstep,
File "/python3.10/site-packages/graph_tool/inference/base_states.py", line 78, in wrapper
ret = func(self, *args, **kwargs)
File "/lib/python3.10/site-packages/graph_tool/inference/uncertain_blockmodel.py", line 208, in mcmc_sweep
return self._algo_sweep(lambda s, **kw: s.multiflip_mcmc_sweep(**kw),
File "/lib/python3.10/site-packages/graph_tool/inference/uncertain_blockmodel.py", line 1333, in _algo_sweep
return self._mcmc_sweep_h(mcmc_state)
File "/lib/python3.10/site-packages/graph_tool/inference/uncertain_blockmodel.py", line 1367, in _mcmc_sweep_h
return libinference.mcmc_ising_glauber_sweep_h(mcmc_state, self._state,
```
This doesn't happen with the equilibrium Ising model classes (substituting in `PseudoIsingBlockState` works fine), . Indeed it seems, by looking at the source code for the C++ side of the library, that the dynamic models do not have those functions implemented (my c++ is rusty tho), however the equilibrium ones have (for example `graph_blockmodel_dynamics_pseudo_cising_mcmc_h.cc`). Also those functions [are explicitly called from the python code](https://git.skewed.de/count0/graph-tool/-/blob/master/src/graph_tool/inference/uncertain_blockmodel.py#L1387), so it seems they should be existing.
Am i misusing the `IsingGlauberBlockState` model or is this an issue with graph-tool?https://git.skewed.de/count0/graph-tool/-/issues/756Error installing bullseye version of graph tool lib in Docker2023-04-21T18:54:15ZGlebError installing bullseye version of graph tool lib in DockerWe are trying to install this library in our docker image, however we are getting this error:
```
=> [ 2/20] RUN echo "deb [ arch=amd64 ] https://downloads.skewed.de/apt bullseye main" >> /etc/apt/sources.list ...We are trying to install this library in our docker image, however we are getting this error:
```
=> [ 2/20] RUN echo "deb [ arch=amd64 ] https://downloads.skewed.de/apt bullseye main" >> /etc/apt/sources.list 1.5s
=> [ 3/20] RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-key 612DEFB798507F25 1.9s
=> ERROR [ 4/20] RUN apt-get update 3.2s
------
> [ 4/20] RUN apt-get update:
#7 0.487 Get:1 http://security.debian.org/debian-security bullseye-security InRelease [48.4 kB]
#7 0.583 Get:2 http://deb.debian.org/debian bullseye InRelease [116 kB]
#7 0.675 Get:3 http://deb.debian.org/debian bullseye-updates InRelease [44.1 kB]
#7 0.699 Get:4 http://security.debian.org/debian-security bullseye-security/main amd64 Packages [237 kB]
#7 0.873 Get:5 http://deb.debian.org/debian bullseye/main amd64 Packages [8183 kB]
#7 1.353 Get:6 http://deb.debian.org/debian bullseye-updates/main amd64 Packages [14.6 kB]
#7 1.476 Ign:7 https://downloads.skewed.de/apt bullseye InRelease
#7 1.630 Err:8 https://downloads.skewed.de/apt bullseye Release
#7 1.630 404 Not Found [IP: 49.12.93.194 443]
#7 2.475 Reading package lists...
#7 3.169 E: The repository 'https://downloads.skewed.de/apt bullseye Release' does not have a Release file.
------
executor failed running [/bin/sh -c apt-get update]: exit code: 100
```
This is the relevant bit from our Dockerfile:
```
# A dockerfile for running the kgtk-browser
# python 3.9.7 is a KGTK 1.1.0 requirement
# this comes with a debian version 11 (bullseye)
FROM python:3.9.7
# Add graph-tool repository to the list of known apt sources
RUN echo "deb [ arch=amd64 ] https://downloads.skewed.de/apt bullseye main" >> /etc/apt/sources.list
# Fetch the public key in order to verify graph-tool
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-key 612DEFB798507F25
# update the registry
RUN apt-get update
# install graph-tool library for kgtk
RUN apt-get install python3-graph-tool -y
```
This directory seems to be empty as of today (2023-04-21):
[https://downloads.skewed.de/apt/dists/bullseye/](https://downloads.skewed.de/apt/dists/bullseye/)https://git.skewed.de/count0/graph-tool/-/issues/755empty `Graph` evaluates to True2023-03-21T16:37:25ZPaul Brodersenempty `Graph` evaluates to True# Bug reports:
## Please follow the general troubleshooting steps first:
- [ ] Are you running the latest `graph-tool` version? -- Nearly
- [ ] Do you observe the problem with the current git version? -- Presumably
- [ ] Are you using ...# Bug reports:
## Please follow the general troubleshooting steps first:
- [ ] Are you running the latest `graph-tool` version? -- Nearly
- [ ] Do you observe the problem with the current git version? -- Presumably
- [ ] Are you using Macports or Homebrew? If yes, please submit an issue there instead: https://github.com/Homebrew/brew/issues and https://trac.macports.org/newticket -- No
- [ ] Did you compile `graph-tool` manually? -- No
- [ ] If you answered yes above, did you use the exact same compiler to build `graph-tool`, `boost-python` and `Python`?
Please replace this section with a brief summary of your issue.
## Do **not** forget to supply the following information:
- [ ] **A _minimal_ and _self-contained_ example that shows the problem.**
- [ ] Your operating system.
- [ ] The Python version you are using.
graph-tool version 2.44, python 3.9.12, Ubuntu 18.04
In graph-tool, an empty `Graph` instance evaluates to True:
```
from graph_tool import Graph
bool(Graph())
# True
```
This is in contrast to python convention:
```
bool(list())
# False
bool(tuple())
# False
bool(dict())
# False
```
Notably, other network analysis libraries adhere to this convention:
```
from networkx import Graph
bool(Graph())
# False
from igraph import Graph
bool(Graph())
# False
```
I am the author of [netgraph](https://github.com/paulbrodersen/netgraph), a graph drawing library that supports various network analysis libraries, and it would make my life easier if I didn't have to check if the data object is a graph-tool `Graph` each time I defend against empty graphs.https://git.skewed.de/count0/graph-tool/-/issues/754Possible regression: add_edge_list() no longer accepts vertex objects?2023-03-16T16:48:05ZAle AbdoPossible regression: add_edge_list() no longer accepts vertex objects?With graph-tool-2.46 tested in Guix and Debian.
Example:
```python
import graph_tool.all as gt
g = gt.Graph()
v0 = g.add_vertex()
v1 = g.add_vertex()
g.add_edge_list([[v0, v1]])
---------------------------------------------------------...With graph-tool-2.46 tested in Guix and Debian.
Example:
```python
import graph_tool.all as gt
g = gt.Graph()
v0 = g.add_vertex()
v1 = g.add_vertex()
g.add_edge_list([[v0, v1]])
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[41], line 1
----> 1 g.add_edge_list([[v0, v1]])
File ~/.guix-profile/lib/python3.9/site-packages/graph_tool/__init__.py:2603, in Graph.add_edge_list(self, edge_list, hashed, hash_type, eprops)
2601 libcore.add_edge_list(self.__graph, edge_list, eprops)
2602 else:
-> 2603 libcore.add_edge_list_iter(self.__graph, edge_list, eprops)
2604 else:
2605 if isinstance(edge_list, numpy.ndarray):
TypeError: No registered converter was able to produce a C++ rvalue of type double from this Python object of type Vertex
```
Workaround:
```
g.add_edge_list([[int(v0), int(v1)]])
```