Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add implementation of transformation of undirected graph to line graph #901

Merged
merged 9 commits into from
Aug 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configuration.conf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pickDeliver | Y | Y | N
vrp_basic | N | Y | Y
vrppdtw | N | Y | Y
withPoints | Y | Y | Y
dijkstraTRSP | Y | Y | Y
#dijkstraTRSP | Y | N | N
lineGraph | Y | Y | Y
#areaContraction | Y | Y | Y
#connectedComponentsV | Y | Y | Y
Expand Down
2 changes: 2 additions & 0 deletions doc/lineGraph/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ foreach (f ${LOCAL_FILES})
list(APPEND LOCAL_DOC_FILES ${PGR_DOCUMENTATION_SOURCE_DIR}/${f})
endforeach()

add_subdirectory("images")
set(PgRouting_DOC_FILES ${PgRouting_DOC_FILES} ${LOCAL_DOC_FILES} PARENT_SCOPE)
set(PgRouting_IMG_FILES ${PgRouting_IMG_FILES} PARENT_SCOPE)
19 changes: 19 additions & 0 deletions doc/lineGraph/images/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
SET(LOCAL_FILES
128px-Line_graph_construction_4.svg.png
135px-Line_graph_construction_1.svg.png
135px-Line_graph_construction_2.svg.png
135px-Line_graph_construction_3.svg.png

Graph1.png
Graph2.png

Line-graph-with-edge-cost.png
Line-graph-with-node-cost.png
)

foreach (f ${LOCAL_FILES})
configure_file(${f} "${PGR_DOCUMENTATION_SOURCE_DIR}/images/${f}" COPYONLY)
list(APPEND LOCAL_IMG_FILES "${PGR_DOCUMENTATION_SOURCE_DIR}/images/${f}")
endforeach()

set(PgRouting_IMG_FILES ${PgRouting_IMG_FILES} ${LOCAL_IMG_FILES} PARENT_SCOPE)
43 changes: 2 additions & 41 deletions doc/lineGraph/pgr_lineGraph.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ The current implementation only works for the `directed graph`.
The following figures show a graph (left, with blue vertices) and its
Line Graph (right, with green vertices).

.. footer::

.. class:: tablapie

+-------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+----------------------------------+-----------------------------------+
| |first| |second| |third| |fourth|

.. |first| image:: images/135px-Line_graph_construction_1.svg.png
Expand All @@ -55,41 +50,7 @@ Line Graph (right, with green vertices).
.. |fourth| image:: images/128px-Line_graph_construction_4.svg.png
:align: middle

Handling of Costs
-------------------------------------------------------------------------------

.. - **Cost associated with the nodes.**
.. + Consider the following graph with nodes having costs:-
..
.. .. image:: images/Graph1.png
..
.. The transformed **Line Graph**:-
..
.. .. image:: images/Line-graph-with-edge-cost.png

.. Each node of the transformed graph is an edge from the original graph.
.. Here `[1,2]` denotes the node in the transformed graph which was an edge
.. from node `1` to node `2` in the original graph.

.. Each edge of the transformed graph is a tuple of nodes `(n1, n2, n3)` where
.. `n1`, `n2` and `n3` are nodes from the original graph such that there was
.. an edge from `n1 -> n2` and another edge from `n2 -> n3`.

.. Thus, the connection `[1,4] -> [3, 4]` goes through the vertex `4` as it is
.. made up of `(1, 4, 3)` tuple which has an associated cost of `6` therefore
.. the corresponding edge in the above graph gets a cost of `6`.

- **Cost associated with the edges**
+ Consider the following graph with edges having costs:-

.. image:: images/Graph2.png

The transformed **Line Graph**:-

.. image:: images/Line-graph-with-node-cost.png

Here, the cost associated with an edge in the original graph moves to the
corresponding nodes in the transformed Line Graph.
.. The images are taken from https://en.wikipedia.org/wiki/Line_graph.

Signature Summary
-----------------
Expand Down Expand Up @@ -205,7 +166,7 @@ See Also
-------------------------------------------------------------------------------

* https://en.wikipedia.org/wiki/Line_graph
* The queries use the :ref:`sampledata` network.
* The queries use the :doc:`sampledata` network.

.. rubric:: Indices and tables

Expand Down
2 changes: 1 addition & 1 deletion doc/queries/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ SET(LOCAL_FILES
trsp_notes_v2.5.0.queries
oneDepotWrapper.queries
doc-gsoc_vrppdtw.queries
doc-pgr_lineGraph.queries
)

foreach (f ${LOCAL_FILES})
Expand All @@ -52,4 +53,3 @@ foreach (f ${LOCAL_FILES})
endforeach()

set(PgRouting_DOC_FILES ${PgRouting_DOC_FILES} ${LOCAL_DOC_FILES} PARENT_SCOPE)

7 changes: 3 additions & 4 deletions doc/src/proposed.rst
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,14 @@ Experimental and Proposed functions
pgr_gsoc_vrppdtw
pgr_vrpOneDepot

.. rubric:: Graph Transformation

.. rubric:: rewrite of pgr_TRSP

- :ref:`pgr_dijkstraTRSP`
:doc:`pgr_lineGraph`

.. toctree::
:hidden:

pgr_dijkstraTRSP
pgr_lineGraph


..
Expand Down
3 changes: 3 additions & 0 deletions include/dijkstraTRSP/pgr_dijkstraTRSP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ Pgr_dijkstraTRSP< G >::dijkstraTRSP(
if (curr_result_path.size() or graph.m_gType == UNDIRECTED)
return curr_result_path;

#if 0
pgrouting::LinearDirectedGraph line(DIRECTED);
line.insert_vertices(edges);
auto line_graph_edges = line.transform(graph);
Expand All @@ -109,6 +110,8 @@ Pgr_dijkstraTRSP< G >::dijkstraTRSP(

line.create_virtual_vertices();
log << line << "\n";
#endif

return curr_result_path;
}

Expand Down
Loading