next | previous | forward | backward | up | top | index | toc | Macaulay2 website
Visualize :: visualize(Digraph)

visualize(Digraph) -- visualizes a digraph in the browser

Synopsis

Description

Using JavaScript, this method creates an interactive visualization of a digraph in a modern browser. While viewing the digraph, the user has the ability to manipulate and run various tests. Once finished, the user can export the finished result back to the Macaulay2 session.

The workflow for this package is as follows. Once we have loaded the package, we first open a port with openPort for Macaulay2 to communicate with the browser. Once a port is established, define an object to visualize. In this example we could use the command openPort"8080" before or after we define the following digraph.

i1 : D = digraph {{1,{2,3}}, {2,{4,5}}, {3,{5,6}}, {4,{7}}, {5,{7}},{6,{7}},{7,{}}}

o1 = Digraph{1 => {2, 3}}
             2 => {4, 5}
             3 => {5, 6}
             4 => {7}
             5 => {7}
             6 => {7}
             7 => {}

o1 : Digraph

At this point we wish to visualize D. To do this simply execute H = visualize D and browser will open with interactive image. You can view this image in the link below.

Visualize Digraphs example

Once finished with a session, you can keep visualizing. For example if you were to say H = visualize D, once you ended the session, the last digraph on the screen would be assigned to H. After running various computations on this digraph, you can then visualize it once more with the visualize method. You can keep using this method until the port is closed with closePort or Macaulay2 is restarted.

Browser Menu Options

On the side of the browser will be several options to interact with the digraph using the Graphs package. Below is a brief overview of the options.

Caveat

When the digraph is exported back to Macaulay2 after ending the visualization session, all vertices are represented as strings. To recover the values of these labels (for example, if they have numeric values or represent ring variables), use the command value first toString G.

See also