How do I make a Mathematica graph from edges with named vertices? EG:
I’ve tried the above and several variations, but Combinatorica never
quite accepts it right. Apparently, Graph[] wants coordinate
positions, which I want Combinatorica to figure out itself.
AddVertex to EmptyGraph[0] (or whatever) also fails.
GraphUtilities isn’t an option, since I want to do fairly complex
analysis on my graphs.
This seems like a simple problem. Graphviz easily creates graphs from
edges with named vertices, so I’m sure Mathematica can too?
I’ve read:
ShowGraph[ { {e1,e2}, {e1, e3} }, {e1,e2,e3} ]; // what is the problem here?
but it doesn’t seem to help with my specific case.
If the sticking point is nodes represented as strings and the heavy-duty graph analysis functions want them as integers, you might consider mapping your strings to integers and vice versa:
Now you have the list of nodes. Next do the mapping to and from integers:
You can now easily convert the nodes to and from integers:
Convert the whole graph like this:
Note that
eachis the following utility function, discussed here: ForEach loop in Mathematica