Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

using GraphPlot I'd like to make directed arrow connecting a vertex (node) to the middle of an edge but couldn't find a way. Is this even possible using GraphPlot or other graphics-related commands in Mathematica.

Basically I'd like to plot enzyme-substrate network and so like to connect node E (enzyme) to an edge connecting substrate S to product P, and scale-up for all Enzyme-Substrate-Product combination.

Any help greatly appreciated!!

share|improve this question
1  
Sounds like you will need to add a new vertex to the graph and connect it to the two nodes of the edge of interest (and to the additional node you mentioned). –  David Carraher Feb 6 at 16:20
    
Thanks David, this is exactly what I was doing and it does work but the network looks a bit messy since the new node doesn't line up with S and P on a straight line. Is there a way to force the new node to line up with S and P? –  user11898 Feb 6 at 16:56
    
Normally you can address this through GraphLayout. But for fine control, as I believe you want in the present example, you'll need to also examine the documentation for VertexCoordinates, and VertexCoordinateRules. –  David Carraher Feb 6 at 17:05
    
And SetProperties –  David Carraher Feb 6 at 17:24
add comment

1 Answer 1

This should work.


The initial graph

g = Graph[{"S", "P", "E"}, {"S" \[UndirectedEdge] "P"}, VertexLabels -> "Name", 
ImagePadding -> 25]

g


1. Add the new node.

g1 = VertexAdd[g, "NewNode"]

g1


2. Add 3 new edges.

g2 = EdgeAdd[ g1, {"S" \[UndirectedEdge] "NewNode", 
"NewNode" \[UndirectedEdge] "P", "NewNode" \[UndirectedEdge] "E"}]

g2


3. Remove SP edge.

g3 = EdgeDelete[g2, {"S" \[UndirectedEdge] "P"}]

g3


4. Tidy up the graph layout

g4=SetProperty[g3, VertexCoordinates -> {{0, 2}, {2, 2}, {1, 1}, {1, 2}}]

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.