Connecting interactive objects in a graph (HGraph)
Source code name: "graph1links.py"
Programming language: Python
Topic: Plots/Graph
DMelt Version 1. Last modified: 10/28/2015. License: Free
https://datamelt.org/code/cache/graph1links_4397.py
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.



from java.awt import Color
from java.util import Random
from jhplot  import HGraph

c1 = HGraph("Canvas",600,400,1, 1)
c1.setGTitle("Connected objects")
c1.visible(1)

v1="v1"
v2="v2"
v3="v3"
v4="v4"

c1.addVertex( v1 )
c1.addVertex( v2 )
c1.addVertex( v3 )
c1.addVertex( v4 )

c1.setPos( v1, 130, 40 )
c1.setPos( v2, 60, 200 )
c1.setPos( v3, 310, 230 )
c1.setPos( v4, 380, 70 )

c1.addEdge( v1, v2 )
c1.addEdge( v2, v3 )
c1.addEdge( v3, v1 )
c1.addEdge( v4, v3 )