protocol
directed_graph_protocol
Protocol for directed graph predicates such as transpose, closures, topological sorting, degree queries, and strongly connected components.
logtalk_load(graphs(loader))staticpublic graph_protocolPublic predicates
transpose/2
Unifies NewGraph with a graph obtained by reversing all edges.
statictranspose(Graph,NewGraph)transpose(+graph,-graph) - onetransitive_closure/2
Generates the transitive closure of the graph.
statictransitive_closure(Graph,Closure)transitive_closure(+graph,-graph) - onesymmetric_closure/2
Generates the symmetric closure of the graph.
staticsymmetric_closure(Graph,Closure)symmetric_closure(+graph,-graph) - onetopological_sort/2
Unifies Sorted with a topological sort of the vertices in the graph. Assumes the graph is a DAG.
statictopological_sort(Graph,Sorted)topological_sort(+graph,-list(vertex)) - onein_degree/3
Unifies Degree with the number of incoming edges to Vertex. Fails if Vertex is not in the graph.
staticin_degree(Vertex,Graph,Degree)in_degree(+vertex,+graph,-integer) - zero_or_oneout_degree/3
Unifies Degree with the number of outgoing edges from Vertex. Fails if Vertex is not in the graph.
staticout_degree(Vertex,Graph,Degree)out_degree(+vertex,+graph,-integer) - zero_or_oneis_acyclic/1
True iff the graph is a directed acyclic graph (DAG).
staticis_acyclic(Graph)is_acyclic(+graph) - zero_or_onehas_cycle/1
True iff the graph contains at least one directed cycle.
statichas_cycle(Graph)has_cycle(+graph) - zero_or_onecycle/2
Enumerates directed cycles as lists of vertices where the first and last vertices are the same.
staticcycle(Graph,Cycle)cycle(+graph,-list(vertex)) - zero_or_morestrongly_connected_components/2
Computes the strongly connected components of the graph using Tarjan’s algorithm. Each component is a sorted list of vertices. Components are returned in topological order.
staticstrongly_connected_components(Graph,SCCs)strongly_connected_components(+graph,-list(list(vertex))) - oneweakly_connected_components/2
Computes the weakly connected components of the graph by considering edge directions as undirected. Each component is returned as a sorted list of vertices.
staticweakly_connected_components(Graph,Components)weakly_connected_components(+graph,-list(list(vertex))) - oneProtected predicates
(no local declarations; see entity ancestors if any)
Private predicates
(no local declarations; see entity ancestors if any)
Operators
(none)