I just spent a couple of hours trying to convert some old code that uses Mathematica 7’s GraphPlot to use the new Mathematica 8 Graph functions. It seemed sensible since the new graph drawing is much nicer and it has things like AdjacencyMatrix and KirchhoffMatrix built in.
The problem is that I can not figure out how to get graphs with multiple edges to work in Mma 8.
The Feynman graph that I use as my canonical example is the two-loop vacuum graph
GraphPlot[{1 -> 2, 1 -> 2, 1 -> 2}, MultiedgeStyle -> .5,
DirectedEdges -> True, VertexCoordinateRules -> {{-1, 0}, {1, 0}}]

Trying to make the similar graph in Mma 8
Graph[{DirectedEdge[1, 2], DirectedEdge[1, 2], DirectedEdge[1, 2]},
VertexCoordinates -> {{-1, 0}, {1, 0}}]
yields the error message
Graph::supp: Mixed graphs and multigraphs are not supported. >>
How can I construct (and work with) a similar graph using Mathematica 8’s Graph[] objects?
Edit: This problem still exists in Mathematica 9
I went through a similar process of trying to use
Graphfor everything, and found that it it does not replaceCombinatoricaandGraphPlot. The best use forGraphis to use it as a container type to store vertices + edges + coordinates.For example, most of the functions from “Algorithmic Graph Theory” of
Combinatoricatutorial are not available for newGraphobjects. When I talked with a WRI developer onGraphproject, my understanding was providing all ofCombinatoricafunctions forGraphis not a priority because the design goal is to provide methods that solve tasks in algorithmic agnostic way. For instance, you may have method to find vertex cover and graph coloring for newGraphobject, but for algorithmic specific tasks like Brelaz coloring and Greedy Vertex Cover, you may always have to defer toCombinatorica.In addition to multi-graphs, some graph layouts are not available for
Graphobjects. You can not fix some vertex coordinates and let automatic layout do the rest. Also, layout ofLayeredGraphPlotis not available and is sometimes preferred overGraph‘sLayeredDrawing.The way to get the best of 3 worlds is to use
Graphobjects as main vehicle for graph storage and make wrappers forGraphPlot,CombinatoricaandGraphUtilitiesfunctions that acceptGraphobjectsSome use cases:
You need some algorithm from
CombinatoricaorGraphUtilities— make a wrappersomeAlgorithmthat takesGraphobject, converts it to list of edges orCombinatoricagraph (GraphUtilities'ToCombinatoricaGraphis helpful), runs the algorithm, converts it back toGraphobject, taking care to set correctGraphStyleandVertexCoordinatesfrom the original graph object. Because of conflicts, make sureCombinatoricaandGraphUtilitiesare not on context path, I do it using $PreYou need some custom graph plot like here, or the multi-edge graph — make a wrapper function
someGraphPlotthat acceptsGraphobject, converts it to correct representation, then usesGraphPlotor perhaps creates a temporaryGraphobject with custom vertex/edge shapes for the purpose of this one plot. Note that you can attach properties to edges usingSetPropertyso you can store your multigraphs inGraphthat way.You want to use one of
GraphPlotlayouts and store coordinates inGraph— use function like here to get vertex coordinates fromGraphPlotlayout, and store them inGraphobject usingVertexCoordinatesHere’s a notebook demonstrating these use cases and a few others