protocol
weighted_graph_protocol
Protocol for weighted graph predicates, extending the common graph protocol with weighted edge operations.
logtalk_load(graphs(loader))staticpublic graph_protocolPublic predicates
edge/4
True iff there is an edge between Vertex1 and Vertex2 with weight Weight in Graph.
staticedge(Vertex1,Vertex2,Weight,Graph)edge(+vertex,+vertex,?number,+graph) - zero_or_oneadd_edge/5
Adds a weighted edge between Vertex1 and Vertex2 with weight Weight.
staticadd_edge(Graph,Vertex1,Vertex2,Weight,NewGraph)add_edge(+graph,+vertex,+vertex,+number,-graph) - onedelete_edge/5
Deletes the weighted edge between Vertex1 and Vertex2. Unifies Weight with the weight of the deleted edge. The graph is unchanged if the edge does not exist.
staticdelete_edge(Graph,Vertex1,Vertex2,Weight,NewGraph)delete_edge(+graph,+vertex,+vertex,?number,-graph) - onewneighbors/3
Unifies WNeighbors with a list of NeighborVertex-Weight pairs for the neighbors of Vertex. Fails if Vertex is not in the graph.
staticwneighbors(Vertex,Graph,WNeighbors)wneighbors(+vertex,+graph,-list(pair)) - zero_or_onemin_path_bellman_ford/5
Finds the minimum cost path from Vertex1 to Vertex2 using the Bellman-Ford algorithm. Supports negative edge weights and fails if no path exists or if a reachable negative cycle makes the optimum undefined.
staticmin_path_bellman_ford(Vertex1,Vertex2,Graph,Path,Cost)min_path_bellman_ford(+vertex,+vertex,+graph,-list(vertex),-number) - zero_or_onehas_negative_cycle/1
True iff Graph contains a negative-weight cycle.
statichas_negative_cycle(Graph)has_negative_cycle(+graph) - zero_or_oneProtected predicates
(no local declarations; see entity ancestors if any)
Private predicates
(no local declarations; see entity ancestors if any)
Operators
(none)