# Trouble representing a problem

I have a problem and I'm having trouble representing it - first I thought I should use graph theory (nodes and edges) and now I'm not sure.

My data is some tanks names and it's volumes, those tanks are connected by pipelines which I have the names and length.

------(pipeline 1)------.-----(pipeline 2)------.----(pipeline 3)---
|                     |    |                           |         |
[R tank 1]        [S tank 1] [S tank 2]            (pipeline 4) [S tank 3]
|
[S tank 4]

R tank is sink (receiver) and S tank is source (sender)


Problem is the pipe names change doesn't occur where there is a tank - they change name because historical reasons, size or connections...

So if I want to graphically show that S tank 2 is connected to pipeline 2 at point X and pipeline 2 connects to pipeline and the content goes to R tank 1, how should I do this? (I think the point X may not be relevant but if I had some way to get the distance travelled would be great).

• I can understand what's going on by what you have already. Are the pipes unidirectional or bidirectional? – JenSCDC Sep 26 '14 at 15:54
• Pipes are unidirectional. In my case there is a only one big receiver tank and many smaller ones that are pumped (one at a time) to the pipelines, so the liquid flows to the big tank. – eri0o Sep 29 '14 at 3:07
• If you are interested in visualizing not only tanks' positions, but also substance flows between the tanks, I would use Sankey diagrams (network flow diagrams). For more details and R examples, check this blog post. If you don't use R, I'm sure that other programming languages, frameworks and ecosystems have similar libraries (for example, d3.js, if you want your diagrams to be Web-enabled). – Aleksandr Blekh Jan 14 '15 at 0:15

I would definitely use a graph (Though, this clearly depends on the final application, maybe you could add more information)

For the nodes, you should consider as nodes not only tanks but also points were pipelines change name or bifurcate. For instance, following your example:

    e1     e2        e3          e4        e5          e7
+---+----------.---------+----------.----------+-----------
|          |         |                     |          |
[R tank 1]  [S tank 1] [S tank 2]              |e6     [S tank 3]
|
[S tank 4]


    e1 n2  e2     n4   e3   n6   e4    n8  e5     n9   e7
n1 +---+----------.---------+----------.----------+----------+
|          |         |                     |              |
n3         n5        n7                     |e6           n11
|
n10


Lastly, you need some kind of mapping. Some of the nodes will map to tanks:

[R tank 1]     n3
[S tank 1]     n5
[S tank 2]     n7
[S tank 4]     n10
[S tank 3]     n11


And the pipelines will be represented by paths in the graph

Pipeline 1     e1 e2
Pipeline 2     e3 e4
Pipeline 3     e5 e7
Pipeline 4     e6