Björn Höhrmann


Graph::SomeUtils - Some utility functions for Graph objects


  use Graph::SomeUtils ':all';

  graph_delete_vertex_fast($g, 'a');
  graph_delete_vertices_fast($g, 'a', 'b', 'c');

  my @pred = graph_all_predecessors_and_self($g, $v);
  my @succ = graph_all_successors_and_self($g, $v);

  my @between = graph_vertices_between($g, $source, $dest);


Some helper functions for working with Graph objects.


graph_delete_vertex_fast($g, $v)

The delete_vertex method of the Graph module v0.96 is very slow. This function is an order-of-magnitude faster alternative. It accesses internals of the Graph module and might break under newer versions of the module.

graph_delete_vertices_fast($g, $v1, $v2, ...)

Same as graph_delete_vertex_fast for multiple vertices.

graph_vertices_between($g, $source, $destination)

Returns the intersection of vertices that are reachable from $source and vertices from which $destination is reachable, including the $source and $destination vertices themself.

graph_all_successors_and_self($g, $v)

Returns the union of $g-all_successors($v)> and $v in an arbitrary order.

graph_all_predecessors_and_self($g, $v)

Returns the union of $g-all_predecessors($v)> and $v in an arbitrary order.

graph_get_vertex_label($g, $v)

Shorthand for getting the vertex attribute label.

graph_set_vertex_label($g, $v, $label)

Shorthand for setting the vertex attribute label.

graph_isolate_vertex($g, $v)

Removes edges coming in and going out of $v.

graph_delete_vertices_except($g, @vertices)

Deletes vertices except @vertices.

graph_truncate_to_vertices_between($g, $start, $final)

Removes all vertices that are neither $start or $final nor on a path between them.


None by default, each of the functions by request. Use :all to import them all at once.


  Copyright (c) 2014 Bjoern Hoehrmann <>.
  This module is licensed under the same terms as Perl itself.