.. index:: single: graph_common
.. _graph_common/0:

.. rst-class:: right

**category**

``graph_common``
================

Common graph predicates shared by all graph objects. Uses self-dispatch to call object-specific predicates such as ``neighbors/3``, ``vertices/2``, and ``edges/2``.

| **Availability:** 
|    ``logtalk_load(graphs(loader))``

| **Author:** Paulo Moura
| **Version:** 1:0:0
| **Date:** 2026-02-25

| **Compilation flags:**
|    ``static``


| **Implements:**
|    ``public`` :ref:`graph_protocol <graph_protocol/0>`
| **Uses:**
|    :ref:`list <list/0>`
|    :ref:`set <set/0>`

| **Remarks:**
|    (none)

| **Inherited public predicates:**
|     :ref:`graph_protocol/0::add_edges/3`  :ref:`graph_protocol/0::add_vertex/3`  :ref:`graph_protocol/0::add_vertices/3`  :ref:`graph_protocol/0::all_pairs_min_paths/2`  :ref:`graph_protocol/0::all_pairs_min_predecessors/2`  :ref:`graph_protocol/0::breadth_first_order/3`  :ref:`graph_protocol/0::delete_edges/3`  :ref:`graph_protocol/0::delete_vertex/3`  :ref:`graph_protocol/0::delete_vertices/3`  :ref:`graph_protocol/0::depth_first_order/3`  :ref:`graph_protocol/0::edges/2`  :ref:`graph_protocol/0::empty/1`  :ref:`graph_protocol/0::has_path/3`  :ref:`graph_protocol/0::is_bipartite/1`  :ref:`graph_protocol/0::is_complete/1`  :ref:`graph_protocol/0::is_sparse/1`  :ref:`graph_protocol/0::max_path/5`  :ref:`graph_protocol/0::min_distances/3`  :ref:`graph_protocol/0::min_path/5`  :ref:`graph_protocol/0::min_predecessors/3`  :ref:`graph_protocol/0::neighbors/3`  :ref:`graph_protocol/0::new/1`  :ref:`graph_protocol/0::new/2`  :ref:`graph_protocol/0::new/3`  :ref:`graph_protocol/0::number_of_edges/2`  :ref:`graph_protocol/0::number_of_vertices/2`  :ref:`graph_protocol/0::path/3`  :ref:`graph_protocol/0::reachable/3`  :ref:`graph_protocol/0::vertices/2`  

.. contents::
   :local:
   :backlinks: top

Public predicates
-----------------

(no local declarations; see entity ancestors if any)

Protected predicates
--------------------

.. index:: pairs_to_edges/2
.. _graph_common/0::pairs_to_edges/2:

``pairs_to_edges/2``
^^^^^^^^^^^^^^^^^^^^

Converts a list of ``Vertex-Neighbors`` pairs from a dictionary into a flat list of ``Vertex1-Vertex2`` edges.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``pairs_to_edges(Pairs,Edges)``
| **Mode and number of proofs:**
|    ``pairs_to_edges(+list(pair),-list)`` - ``one``


------------

.. index:: vertex_neighbors_to_edges/4
.. _graph_common/0::vertex_neighbors_to_edges/4:

``vertex_neighbors_to_edges/4``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Converts a neighbor list for a vertex into edges using a difference list.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``vertex_neighbors_to_edges(Neighbors,Vertex,Edges,RestEdges)``
| **Mode and number of proofs:**
|    ``vertex_neighbors_to_edges(+list,+vertex,-list,-list)`` - ``one``


------------

.. index:: wpairs_to_edges/2
.. _graph_common/0::wpairs_to_edges/2:

``wpairs_to_edges/2``
^^^^^^^^^^^^^^^^^^^^^

Converts a list of ``Vertex-WNeighbors`` pairs from a dictionary into a flat list of ``(Vertex1-Vertex2)-Weight`` weighted edges.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``wpairs_to_edges(Pairs,Edges)``
| **Mode and number of proofs:**
|    ``wpairs_to_edges(+list(pair),-list)`` - ``one``


------------

.. index:: wvertex_neighbors_to_edges/4
.. _graph_common/0::wvertex_neighbors_to_edges/4:

``wvertex_neighbors_to_edges/4``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Converts a weighted neighbor list for a vertex into weighted edges using a difference list.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``wvertex_neighbors_to_edges(WNeighbors,Vertex,Edges,RestEdges)``
| **Mode and number of proofs:**
|    ``wvertex_neighbors_to_edges(+list,+vertex,-list,-list)`` - ``one``


------------

Private predicates
------------------

(no local declarations; see entity ancestors if any)

Operators
---------

(none)

