Guest User

Untitled

a guest
Jan 28th, 2018
90
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (* This also catches the 0-vertex graph: *)
  2. rebuildGraph[g_?EmptyGraphQ, opt : OptionsPattern[]] := Graph[VertexList[g], {}, opt]
  3.  
  4. rebuildGraph[g_?DirectedGraphQ, opt : OptionsPattern[]] := Graph[VertexList[g], {AdjacencyMatrix[g], Null}, opt]
  5.  
  6. rebuildGraph[g_?UndirectedGraphQ, opt : OptionsPattern[]] := Graph[VertexList[g], {Null, AdjacencyMatrix[g]}, opt]
  7.  
  8. (* This last one catches the mixed graph case, which I do not particularly care about: *)
  9. rebuildGraph[g_?GraphQ, opt : OptionsPattern[]] := Graph[VertexList[g], EdgeList[g], opt]
RAW Paste Data