category

# `weighted_graph_common(Dictionary)`

Common weighted graph predicates shared by both weighted directed and weighted undirected graph objects. Uses self-dispatch to call object-specific predicates such as `add_edge/5`, `delete_edge/5`, and `edges/2`.

Availability:
`logtalk_load(graphs(loader))`
Author: Paulo Moura
Version: 1:0:0
Date: 2026-02-25
Compilation flags:
`static`
Implements:
`public` weighted_graph_protocol
Extends:
`public` graph_common
Uses:
list
pairs
Remarks:
(none)
Inherited public predicates:
add_edge/5 add_edges/3 add_vertex/3 add_vertices/3 all_pairs_min_paths/2 all_pairs_min_predecessors/2 breadth_first_order/3 delete_edge/5 delete_edges/3 delete_vertex/3 delete_vertices/3 depth_first_order/3 edge/4 edges/2 empty/1 has_negative_cycle/1 has_path/3 is_bipartite/1 is_complete/1 is_sparse/1 max_path/5 min_distances/3 min_path/5 min_path_bellman_ford/5 min_predecessors/3 neighbors/3 new/1 new/2 new/3 number_of_edges/2 number_of_vertices/2 path/3 reachable/3 vertices/2 wneighbors/3

## Public predicates

(no local declarations; see entity ancestors if any)

## Protected predicates

### `winsert_neighbor/4`

Inserts a weighted neighbor into a sorted weighted neighbor list, replacing any existing entry for the same vertex.

Compilation flags:
`static`
Template:
`winsert_neighbor(WNeighbors,Vertex,Weight,NewWNeighbors)`
Mode and number of proofs:
`winsert_neighbor(+list,+vertex,+number,-list)` - `one`

### `wremove_neighbor/4`

Removes a vertex from a sorted weighted neighbor list, unifying the weight. Fails if the vertex is not found.

Compilation flags:
`static`
Template:
`wremove_neighbor(WNeighbors,Vertex,Weight,NewWNeighbors)`
Mode and number of proofs:
`wremove_neighbor(+list,+vertex,-number,-list)` - `zero_or_one`

### `wfind/3`

Finds the weight associated with a vertex in a weighted neighbor list.

Compilation flags:
`static`
Template:
`wfind(WNeighbors,Vertex,Weight)`
Mode and number of proofs:
`wfind(+list,+vertex,-number)` - `zero_or_one`

### `wremove_vertex_from_all/3`

Removes a vertex from all weighted neighbor lists in a list of vertex-neighbors pairs.

Compilation flags:
`static`
Template:
`wremove_vertex_from_all(Pairs,Vertex,NewPairs)`
Mode and number of proofs:
`wremove_vertex_from_all(+list(pair),+vertex,-list(pair))` - `one`

### `relax_neighbors/7`

Relaxes neighbors during Dijkstra shortest path computation, updating distances and priority queue.

Compilation flags:
`static`
Template:
`relax_neighbors(WNeighbors,Vertex,Distance,Queue,Dist,NewQueue,NewDist)`
Mode and number of proofs:
`relax_neighbors(+list,+vertex,+number,+list,+dictionary,-list,-dictionary)` - `one`

### `pq_insert/3`

Inserts an element into a sorted priority queue (list of Distance-Vertex pairs).

Compilation flags:
`static`
Template:
`pq_insert(Queue,Item,NewQueue)`
Mode and number of proofs:
`pq_insert(+list,+pair,-list)` - `one`

## Private predicates

(no local declarations; see entity ancestors if any)

## Operators

(none)