[Date Index]
[Thread Index]
[Author Index]
Re: Adding an edge to a directed cyclic graph
*To*: mathgroup at smc.vnet.net
*Subject*: [mg88962] Re: [mg88908] Adding an edge to a directed cyclic graph
*From*: Murray Eisenberg <murray at math.umass.edu>
*Date*: Thu, 22 May 2008 02:38:04 -0400 (EDT)
*Organization*: Mathematics & Statistics, Univ. of Mass./Amherst
*References*: <200805211848.OAA10337@smc.vnet.net>
*Reply-to*: murray at math.umass.edu
Aside from explicitly changing the embedding coordinates of vertices in
the Graph object, offhand the only ways I know to change the location of
vertices for ShowGraph by Mathematica commands are the Combinatorica
functions ShakeGraph and SpringEmbedding. But some other methods are:
other options are:
(1) Use GraphPlot instead of ShowGraph and then manually move the
vertex by clicking in its vicinity until you see a small graphics square
highlighted, then drag to a new position.
(2) Use Levon Lloyd's visual graph editor, which exports in
Combinatorica Graph type form.
Undoubtedly it would not be terribly difficult to construct a Dynamic
expression that uses locators in order to create and move vertices and
edges for a graph. This could just reproduce the behavior of Lloyd's
visual editor, so it's not clear what would be gained except that
everything could be done strictly within Mathematica.
You might find helpful the guide to Combinatorica'a graph functions (and
to the kernel's GraphPlot function) that I used for my Discrete
Structures course. See the item "Graphs.nb" on the Files page at:
www.math.umass.edu/Courses/Math_455_Eisenberg
W_Craig Carter wrote:
> 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*)
--
Murray Eisenberg murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305
Prev by Date:
**Re: Cannot NSolve a system of equations**
Next by Date:
**Re: Wolfram Workbench user experiences**
Previous by thread:
**Adding an edge to a directed cyclic graph**
Next by thread:
**URL button on Documentation Center pages**
| |