BFSVisitor initialize_vertex() not invoked

Bug reports:

Troubleshooting

  • Are you running the latest graph-tool version?
  • Do you observe the problem with the current git version?

I am afraid I haven't had a chance to build this, but I have replicated the bug on another device.

  • Did you compile graph-tool manually?

I installed graph-tool from the AUR.

Issue Summary

BFSVisitor's initialize_vertex() method is not being invoked on vertices. The program below terminates, instead of exiting with an error inside initialize_vertex().

Example:

import graph_tool.all as gt
import sys


class InitializeVisitor(gt.BFSVisitor):

    def initialize_vertex(self, u):
        print('This method appears to be bugged.')
        print('This code will terminate the program if it is reached.')
        sys.exit(1)

    def discover_vertex(self, u):
        print('This other method works fine.')


graph = gt.Graph()
a = graph.add_vertex()
b = graph.add_vertex()
c = graph.add_vertex()
d = graph.add_vertex()
graph.add_edge(a, b)
graph.add_edge(c, d)
graph.add_edge(a, c)

gt.bfs_search(graph, a, InitializeVisitor())
print('This should not be reached.')

Output:

This other method works fine.
This other method works fine.
This other method works fine.
This other method works fine.
This should not be reached.

System Information (both devices):

Operating System: Manjaro Linux Qonos 21.2.2
Python version: 3.10.1
Boost version: 1.78.0-1
Compiler version: g++ (GCC) 11.1.0
Edited by Damian Lin