Pergunta

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).

Foi útil?

Solução

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]            

Now adding the nodes:

    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                                                   
Licenciado em: CC-BY-SA com atribuição
scroll top