Has anybody figured out a way to modify Graph objects in Mathematica 8? In particular, how to get the same functionality you get when you right click on the graph.
Some of the new graph functions conflict with
Combinatorica
, is there a way to force Mathematica to use a built-in version of the function? In other words, is there a way to get access to built-inCompleteGraph
after I doNeeds["Combinatorica"]
which imports Combinatorica version ofCompleteGraph
?
To clarify 1, Context Menu on Graph lets you change GraphStyle and GraphLayout, and I'd like to be able to change them programmatically. Here's one way I found to change GraphStyle of Graph object
g = GridGraph[{4, 4}];
BooleanGraph[Or, g, g, GraphStyle -> "DiagramBlack"]
However, that forgets options of the original graph like VertexCoordinates
Trying Brett's recipe on grid graph
g = GridGraph[{3, 2}, ImageSize -> Tiny]
coords = PropertyValue[{g, #}, VertexCoordinates] & /@ VertexList[g];
Graph[EdgeList[g], GraphStyle -> "BasicGold",
VertexCoordinates -> coords, ImageSize -> Tiny]
(source: yaroslavvb.com)
There seems to be a bug with how Mathematica handles Graph coordinates on graph operations. First line below permutes coordinates, second gives internal warning, probably related to coordinates. Using non-integer vertices and explicit coordinates for each vertex doesn't help. One solution is to store coordinates globally and have fixCoordinates
function to reassign correct coordinates to Graph
after modifications
VertexDelete[GridGraph[{3, 3}], 1]
NeighborhoodGraph[VertexDelete[GridGraph[{3, 3}], 1], 2]