2
$\begingroup$

I let Mathematica 7 construct a list of lists of vertex pairs, e.g.:

s = { {{1,2},{2,3}}, {{1,2},{1,3}} }

The s of the example contains two directed graphs. How can I say Mathematica 7 to construct the corresponding list of Mathemtica graphs by Graph or by MakeGraph?

$\endgroup$
2
$\begingroup$

Mathematica 7 has no built-in support for graphs. You are probably referring to the separate Combinatorica package, which is described in the book Computational Discrete Mathematics. Do not confuse it with the built-in Graph and related functionality introduced in Mathematica 8.

The function to use from that package is FromOrderedPairs.

FromOrderedPairs[{{1, 2}, {2, 3}}]
(* -Graph[<2,3,Directed>]- *)

ShowGraph[%]

enter image description here

With this function, the graph edges are specified as a list of vertex-index pairs.

I think that using Combinatorica is quite difficult without having a copy of the book I mentioned above. There's some documentation that comes with it, but it's quite bare-bones.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.