2
$\begingroup$

I was trying to plot a 9x9 adjacency matrices which produce a useless directed graph.

Codes for that I used:

AbsoluteOptions[GridGraph[{3, 3}], VertexCoordinates]
VertexCoordinates -> Automatic
Manipulate[x = ConstantArray[0, 9 {1, 1}];
Row[{EventHandler[Dynamic[tds = Reverse[Transpose[x]];
MatrixPlot[tds, PlotRangePadding -> 0, Mesh -> All, ImageSize -> {200, 400}, ColorRules -> {1 -> Green, 0 -> None}]],
{"MouseClicked" :> (pos = Ceiling[MousePosition["Graphics"]];
x = ReplacePart[x, pos -> 1 - x[[Sequence @@ pos]]];)}],
Dynamic@AdjacencyGraph[tds, AbsoluteOptions[GridGraph[{3, 3}],
VertexCoordinates], ImageSize -> {300, 300},
PlotRange -> {{.5, 3.5}, {.5, 3.5}},
VertexStyle -> Directive[Red, Opacity[.3]], VertexSize -> .2,
VertexLabels -> "Name", EdgeStyle -> Thick, DirectedEdges -> True]}],
{pos, ControlType -> None}, {x, ControlType -> None}, {tds, ControlType -> None}, AppearanceElements -> None, FrameMargins -> 0]

Here are the coordinates as an example:

{1,3}, {3,3}, {3,4}, {4,3}

to use click on cells with given coordinates,

output look like: enter image description here

Arrow between nodes number 1 and 3 pass over the node number 2 and another strange half arrow on node 3. It´s might not be able with GridGraph.

I don`t know really how can I visualise this graph better?

Thanks for your help.

$\endgroup$
2
  • $\begingroup$ What is your question exactly? I don't understand. $\endgroup$ Commented Sep 5, 2015 at 14:25
  • $\begingroup$ how can I resulting that graph better visualize (another Graphform)? I wanted for example, no arrow pass over the node like this given pictures. After the fulfillment of the adjacencymatrix I would not plot in GridGraph Form. $\endgroup$ Commented Sep 5, 2015 at 15:02

1 Answer 1

2
$\begingroup$

Add the option

EdgeShapeFunction -> (Arrow[GraphElementData["CurvedArc"][##], .1] &)

to AdjacencyGraph[...] to get

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.