Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Adding an edge to a directed cyclic graph

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88908] Adding an edge to a directed cyclic graph
  • From: "W_Craig Carter" <ccarter at mit.edu>
  • Date: Wed, 21 May 2008 14:48:43 -0400 (EDT)

Sorry to ask a question that probably has an answer in the
Combinatorica book; I've just purchased it and waiting for delivery.

I am teaching myself discrete math by learning Combinatorica. Is there
an obvious way to add an edge to a directed graph and have
the edges renumbered associated with the cyclic order?  The number of
vertices are fixed.

This seems like a common thing to do; so before embarking on my own
code to do this, I am hoping I am missing an obvious built-in.

For example:

Needs["Combinatorica`"]

(*c6 is the cycle in which I'd like to insert and edge*)

c6 = Cycle[6, Type -> Directed]
ShowGraph[c6, VertexNumber -> True, EdgeLabel -> True,
 EdgeLabelColor -> Darker[Orange], BaseStyle -> Large]

(*here I hope to add a sub-loop to replace the edge going from 4-5*)
modc6 = AddEdges[
  DeleteEdge[c6, {4, 5}],
  {
   {{4, 5}, EdgeColor -> Green},
   {{5, 4}, EdgeColor -> Blue},
   {{4, 5}, EdgeColor -> Red}
   }
  ]

(*the edge numbering no longer corresponds to the cycle index--what I
need is a "ReplaceEdge"*)

ShowGraph[modc6, VertexNumber -> True, EdgeLabel -> True,
 EdgeLabelColor -> Darker[Orange], BaseStyle -> Large]

(*does anyone know an option to increase the "bowing angle" of the
Graphics for the subloop?*)

(*thanks*)
-- 
W. Craig Carter


  • Prev by Date: intersecting a hypercube and a hyperplane
  • Next by Date: Re: Problems with ListPlot
  • Previous by thread: Re: intersecting a hypercube and a hyperplane
  • Next by thread: Re: Adding an edge to a directed cyclic graph