This seems to calculate the max flow (edges have "capacity"):

source.outE.inV.loop(2){!it.object.equals(sink)}.paths.each{flow =
it.capacity.min(); maxFlow += flow;
it.findAll{it.capacity}.each{it.capacity -= flow}};

I can't believe this is so short!

A



On Fri, Nov 18, 2011 at 10:51 PM, Marko A. Rodriguez
<okramma...@gmail.com> wrote:
>> Great! Thanks.
>>
>> Also its missing the "!"... should be
>> "source.outE.inV.loop(2){!it.object.equals(sink)}.paths.each{"
>>
>
> Yes...good catch.
>
> Good luck,
> Marko.
>
> http://markorodriguez.com
>
>
>
>
>>
>>
>> On Fri, Nov 18, 2011 at 9:47 PM, Marko Rodriguez <okramma...@gmail.com> 
>> wrote:
>>> Hey,
>>>
>>> Perhaps the simplist way to explore flow is to simply get the paths between 
>>> source and sink and then calculate some function f over the path to 
>>> determine its flow. For example:
>>>
>>>        def f = { List path ->
>>>                // some function over the path where every other element is 
>>> an edge (see traversal below)
>>>        }
>>>
>>>        source.outE.inV.loop(2){it.object.equals(sink)}.paths.each{
>>>                println(it + " has a flow of " + f(it))
>>>        }
>>>
>>> This assumes you have a determined source and a determined sink and that 
>>> there are no cycles in your gas pipeline. If there are cycles, then you can 
>>> tweak the expression to make sure you break out of the loop when 
>>> appropriate.
>>>
>>> From this basic idea you can then tweak it to simulate decay over time/step 
>>> or implement random walks through the gasline if you are interested in 
>>> sampling or studying local eigenvectors in the pipeline.
>>>
>>> Hope that provides you a good starting point.
>>>
>>> Enjoy!,
>>> Marko
>>>
>>> http://markorodriguez.com
>>>
>>> On Nov 18, 2011, at 1:20 PM, Alfredas Chmieliauskas wrote:
>>>
>>>> Hey Marko,
>>>>
>>>> I'm modeling the european gas transport/pipeline network. I need to
>>>> have a good way to calculate maximum flow from source to sink and get
>>>> the nodes in the path .
>>>>
>>>> Alfredas
>>>>
>>>> On Fri, Nov 18, 2011 at 2:48 PM, Marko Rodriguez <okramma...@gmail.com> 
>>>> wrote:
>>>>> Hi,
>>>>>
>>>>>> has anyone implemented any of the max flow algorithms using gremlin?
>>>>>
>>>>> Most of the algorithms in my toolbox are flow-based algorithms. What in 
>>>>> particular are you trying to do?
>>>>>
>>>>> Marko.
>>>>>
>>>>> http://markorodriguez.com
>>>>> _______________________________________________
>>>>> Neo4j mailing list
>>>>> User@lists.neo4j.org
>>>>> https://lists.neo4j.org/mailman/listinfo/user
>>>>>
>>>> _______________________________________________
>>>> Neo4j mailing list
>>>> User@lists.neo4j.org
>>>> https://lists.neo4j.org/mailman/listinfo/user
>>>
>>> _______________________________________________
>>> Neo4j mailing list
>>> User@lists.neo4j.org
>>> https://lists.neo4j.org/mailman/listinfo/user
>>>
>> _______________________________________________
>> Neo4j mailing list
>> User@lists.neo4j.org
>> https://lists.neo4j.org/mailman/listinfo/user
> _______________________________________________
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>
_______________________________________________
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to