I've searched for a solution to my problem a couple of days, and I didn't find one. Hope you guys can help me.
I'm currently trying to solve some graph-theoretical problems. One of them is to find the maximum flow throughout a graph. I've managed to draw the graph in Mathematica, and would now like to use the built-in function NetworkFlow
. To do this I need to load the package Combinatorica
, but that gives me problems with "shadowed" functions. I've tried to refer to them by their fully qualified names, e.g., Combinatorica
`NetworkFlow
, etc., but I still can't get it to work.
I've pasted in some code which I hope will make it easier to see what I'm doing wrong:
Graph[{Kø -> Ro, Kø -> Pu, Kø -> Pa, Ro -> Ha, Ro -> Be, Pu -> Ha,
Pu -> Be, Pa -> Ha, Ha -> Be, Ha -> St, Ha -> Br, Ha -> Li,
Be -> St, Be -> Br, Be -> Li, St -> Br, St -> Li, St -> Par,
Br -> Li, Br -> Par, Li -> Par},
EdgeWeight -> {"2", "11", "8", "3", "5", "14", "11", "10", "12",
"12", "10", "10", "4", "4", "12", "4", "12", "11", "23", "16",
"10"}, VertexLabels -> "Name", ImagePadding -> 10,
GraphLayout -> "SpringEmbedding"]
Which gives me a nice graph. Below is the "real" problem:
Needs["Combinatorica`"]
Graph[{Kø -> Ro, Kø -> Pu, Kø -> Pa, Ro -> Ha, Ro -> Be, Pu -> Ha,
Pu -> Be, Pa -> Ha, Ha -> Be, Ha -> St, Ha -> Br, Ha -> Li,
Be -> St, Be -> Br, Be -> Li, St -> Br, St -> Li, St -> Par,
Br -> Li, Br -> Par, Li -> Par},
EdgeWeight -> {"2", "11", "8", "3", "5", "14", "11", "10", "12",
"12", "10", "10", "4", "4", "12", "4", "12", "11", "23", "16",
"10"}, VertexLabels -> "Name", ImagePadding -> 10,
GraphLayout -> "SpringEmbedding"]
Combinatorica`NetworkFlow[%, Kø, Par]
During evaluation of In[28]:= General::compat: Combinatorica Graph and Permutations functionality has been superseded by preloaded functionaliy. The package now being loaded may conflict with this. Please see the Compatibility Guide for details.
Out[29]= Graph({Kø->Ro,Kø->Pu,Kø->Pa,Ro->Ha,Ro->Be,Pu->Ha,Pu->Be,Pa->Ha,Ha->Be,Ha->St,Ha->Br,Ha->Li,Be->St,Be->Br,Be->Li,St->Br,St->Li,St->Par,Br->Li,Br->Par,Li->Par},EdgeWeight->{2,11,8,3,5,14,11,10,12,12,10,10,4,4,12,4,12,11,23,16,10},VertexLabels->Name,ImagePadding->10,GraphLayout->SpringEmbedding)
Out[30]= NetworkFlow(Graph({Kø->Ro,Kø->Pu,Kø->Pa,Ro->Ha,Ro->Be,Pu->Ha,Pu->Be,Pa->Ha,Ha->Be,Ha->St,Ha->Br,Ha->Li,Be->St,Be->Br,Be->Li,St->Br,St->Li,St->Par,Br->Li,Br->Par,Li->Par},EdgeWeight->{2,11,8,3,5,14,11,10,12,12,10,10,4,4,12,4,12,11,23,16,10},VertexLabels->Name,ImagePadding->10,GraphLayout->SpringEmbedding),Kø,Par)
Read the FAQs
! 3) When you see good Q&A, vote them up byclicking the gray triangles
, because the credibility of the system is based on the reputation gained by users sharing their knowledge. ALSO, remember to accept the answer, if any, that solves your problem,by clicking the checkmark sign
` – Vitaliy Kaurov Nov 28 '12 at 23:20