I suppose thatwrote some code for drawing a graph interactively using interactively meansDynamicModule and changing some parametersEventHandler. For this, youYou can simply useadd vertices with right click and edges with left-click. The adjacency list is printed at the bottom. Admittedly, the graph is stored as a list of points (in the graphics object coordinates), not a ManipulateGraph. Also, the style of the edges is fixed.
Manipulate[Column[DynamicModule[{CompleteGraph[p]newEdge = {}, AdjacencyMatrix[CompleteGraph[p]]edges = {}, vertices = {}, pos = {}},
Dynamic[
EventHandler[
Column[{
Framed@
Graphics[{Black, Line[edges], PointSize[0.05], Red,
Point /@ vertices}, PlotRange -> {{0, 10}, {0, 10}},
ImageSize -> 300],
edges
},
Spacings -> 10
],
{p
{"MouseClicked", 1} :> (
If[Length[newEdge] > 0,
50 Print["Please select a second vertex!"],
1 pos = Round[MousePosition["Graphics"]];
If [MemberQ[vertices, pos],
Print["Vertex already exists!"],
AppendTo[vertices, pos]
]
]
),
{"MouseClicked", 2} :> (
pos = Round[MousePosition["Graphics"]];
If[MemberQ[vertices, pos],
AppendTo[newEdge, pos];
If[Length[newEdge] == 2,
AppendTo[edges, newEdge];
newEdge = {}
]
]
)
}
]
]
]
Example output is attached below.