GLG Toolkit, C / C++ API Library  Version 4.5
Layout Functions

Detailed Description

Functions

GlgGraphEdge GlgGraphAddEdge (GlgGraphLayout graph, GlgGraphNode start_node, GlgGraphNode end_node, GlgObject graphics, GlgLong edge_type, void *data)
 Creates a new edge and adds it to the graph. More...
 
GlgGraphNode GlgGraphAddNode (GlgGraphLayout graph, GlgObject graphics, GlgLong node_type, void *data)
 Creates a new node and adds it to the graph. More...
 
void GlgGraphCircularLayout (GlgGraphLayout graph)
 Performs a circular layout. More...
 
GlgGraphLayout GlgGraphCreate (void)
 Creates a graph layout object. More...
 
GlgBoolean GlgGraphCreateGraphics (GlgGraphLayout graph, GlgObject viewport, GlgObject group)
 Loads icons from the palette and creates a GLG drawing to render the graph. More...
 
GlgGraphLayout GlgGraphCreateRandom (GlgLong num_nodes, GlgLong num_node_types, GraphType type)
 Creates a demo graph layout and populates it with nodes and edges. More...
 
void GlgGraphDeleteEdge (GlgGraphLayout graph, GlgGraphEdge edge)
 Deletes an edge from the graph. More...
 
void GlgGraphDeleteNode (GlgGraphLayout graph, GlgGraphNode node)
 Deletes a node from the graph. More...
 
void GlgGraphDestroy (GlgGraphLayout graph)
 Destroys all graph layout's objects. More...
 
void GlgGraphDestroyGraphics (GlgGraphLayout graph)
 Destroys the graph's drawing and all graphical objects used to render nodes and edges. More...
 
void GlgGraphError (char *message)
 Error handler. More...
 
GlgGraphEdge GlgGraphFindEdge (GlgGraphLayout graph, GlgObject edge_graphics)
 Finds an edge object by its graphics. More...
 
GlgGraphNode GlgGraphFindNode (GlgGraphLayout graph, GlgObject node_graphics)
 Finds a node object by its graphics. More...
 
GlgGraphEdge GlgGraphGetEdge (GlgGraphLayout graph, GlgLong index)
 Finds an edge object by its index. More...
 
GlgLong GlgGraphGetEdgeIndex (GlgGraphLayout graph, GlgGraphEdge edge)
 Returns an edge's index inside the graph's edge_array. More...
 
GlgObject GlgGraphGetGroup (GlgGraphLayout graph)
 Queries the container used to hold graph's nodes and edges. More...
 
GlgGraphNode GlgGraphGetNode (GlgGraphLayout graph, GlgLong index)
 Finds a node object by its index. More...
 
GlgLong GlgGraphGetNodeIndex (GlgGraphLayout graph, GlgGraphNode node)
 Returns a node's index inside the graph's node array. More...
 
void GlgGraphGetNodePosition (GlgGraphLayout graph, GlgGraphNode node, double *x, double *y, double *z)
 Queries node position. More...
 
GlgBoolean GlgGraphGetUntangle (GlgGraphLayout graph)
 Queries if the untangling algorithm was enabled via GlgGraphSetUntangle. More...
 
GlgObject GlgGraphGetViewport (GlgGraphLayout graph)
 Queries the viewport of the graph's drawing. More...
 
void GlgGraphIncreaseTemperature (GlgGraphLayout graph, GlgBoolean initial)
 Forces the graph to continue layout after it's finished. More...
 
GlgBoolean GlgGraphNodesConnected (GlgGraphNode node1, GlgGraphNode node2)
 Connectivity test. More...
 
void GlgGraphScramble (GlgGraphLayout graph)
 Demo function: Randomly scrambles the graph's nodes. More...
 
void GlgGraphSetDefPalette (GlgObject palette_drawing)
 Sets the default icon palette. More...
 
void GlgGraphSetNodePosition (GlgGraphLayout graph, GlgGraphNode node, double x, double y, double z)
 Sets node position in the GLG world coordinates within the graph's dimensions. More...
 
void GlgGraphSetPalette (GlgGraphLayout graph, GlgObject palette_drawing)
 Sets a graph's icon palette. More...
 
void GlgGraphSetUntangle (GlgGraphLayout graph, GlgBoolean untangle)
 Enables or disables untangling algorithm. More...
 
GlgBoolean GlgGraphSpringIterate (GlgGraphLayout graph)
 Performs one iteration of the spring embedder layout. More...
 
void GlgGraphUnloadDefPalette (void)
 Unsets the default palette. More...
 
void GlgGraphUpdate (GlgGraphLayout graph)
 Updates the graphics display to show results of the spring layout. More...
 

Function Documentation

◆ GlgGraphAddEdge()

GlgGraphEdge GlgGraphAddEdge ( GlgGraphLayout  graph,
GlgGraphNode  start_node,
GlgGraphNode  end_node,
GlgObject  graphics,
GlgLong  edge_type,
void *  data 
)

Creates a new edge and adds it to the graph.

Parameters
graphGraph layout object.
start_nodeThe edge's start node.
end_nodeThe edge's end node.
graphicsAn optional custom edge icon (to override the icon from the palette).
edge_typePalette index, specifies what icon to use from the edge palette if no custom graphics is specified. This parameter is reserved for the future use and the value of 0 must be used for regular nodes. The value of -1 can be used to define an external edge with no graphics that connects to an external node.
dataCustom data that will be attached to the edge.
Returns
New edge object

◆ GlgGraphAddNode()

GlgGraphNode GlgGraphAddNode ( GlgGraphLayout  graph,
GlgObject  graphics,
GlgLong  node_type,
void *  data 
)

Creates a new node and adds it to the graph.

Parameters
graphGraph layout object.
graphicsAn optional custom node icon (to override the icon from the palette.)
node_typePalette index, specifies what icon to use from the node palette if no custom graphics is specified. The value of -1 can be used to define an external node with no graphics. External nodes will not be moved by the layout.
dataCustom data that will be attached to the node.
Returns
New node object.

When a node is created, it is assigned a random initial position. An application can assign a node's initial position in normalized coordinates using GlgNodePosition after the node is created.

◆ GlgGraphCircularLayout()

void GlgGraphCircularLayout ( GlgGraphLayout  graph)

Performs a circular layout.

Parameters
graphGraph layout object.

◆ GlgGraphCreate()

GlgGraphLayout GlgGraphCreate ( void  )

Creates a graph layout object.

Returns
A new graph layout object.

◆ GlgGraphCreateGraphics()

GlgBoolean GlgGraphCreateGraphics ( GlgGraphLayout  graph,
GlgObject  viewport,
GlgObject  group 
)

Loads icons from the palette and creates a GLG drawing to render the graph.

Parameters
graphGraph layout object.
viewportAn optional viewport parameter. If it's not NULL, it will be used as a viewport for the graph's drawing, rendering the graph in an existing object hierarchy. If it's NULL, the graph will create a new viewport to render the graph.
groupAn optional group parameter. If it's not NULL, it defines the group container to add nodes and edges to (used when several graph layouts reside in the same viewport). If it's NULL, the graph's viewport is used as a container.
Returns
Success or failure status.

◆ GlgGraphCreateRandom()

GlgGraphLayout GlgGraphCreateRandom ( GlgLong  num_nodes,
GlgLong  num_node_types,
GraphType  type 
)

Creates a demo graph layout and populates it with nodes and edges.

Parameters
num_nodesNumber of nodes to create.
num_node_typesNumber of node types to use for rendering.
typeGraph type constant: RANDOM_GRAPH, CIRCULAR_GRAPH or STAR_GRAPH.
Returns
The graph layout object.

◆ GlgGraphDeleteEdge()

void GlgGraphDeleteEdge ( GlgGraphLayout  graph,
GlgGraphEdge  edge 
)

Deletes an edge from the graph.

Parameters
graphGraph layout object.
edgeThe edge object to be deleted.

◆ GlgGraphDeleteNode()

void GlgGraphDeleteNode ( GlgGraphLayout  graph,
GlgGraphNode  node 
)

Deletes a node from the graph.


It also delets all edges connected to the node.

Parameters
graphGraph layout object.
nodeThe node object to be deleted.

◆ GlgGraphDestroy()

void GlgGraphDestroy ( GlgGraphLayout  graph)

Destroys all graph layout's objects.

Parameters
graphGraph layout object.

◆ GlgGraphDestroyGraphics()

void GlgGraphDestroyGraphics ( GlgGraphLayout  graph)

Destroys the graph's drawing and all graphical objects used to render nodes and edges.

Parameters
graphGraph layout object.

◆ GlgGraphError()

void GlgGraphError ( char *  message)

Error handler.

It uses the default GLG error handler to display the supplied error message and may be overridden by subclasses to implement custom error handling.

Parameters
messageAn error message.

◆ GlgGraphFindEdge()

GlgGraphEdge GlgGraphFindEdge ( GlgGraphLayout  graph,
GlgObject  edge_graphics 
)

Finds an edge object by its graphics.

It is used to handle mouse selection.

Parameters
graphGraph layout object.
edge_graphicsThe graphical object used to render the edge in the drawing.
Returns
The edge object associated with edge_graphics.

◆ GlgGraphFindNode()

GlgGraphNode GlgGraphFindNode ( GlgGraphLayout  graph,
GlgObject  node_graphics 
)

Finds a node object by its graphics.

It is used to handle mouse selections.

Parameters
graphGraph layout object.
node_graphicsThe graphical object used to render the node in the drawing.
Returns
The node object associated with node_graphics.

◆ GlgGraphGetEdge()

GlgGraphEdge GlgGraphGetEdge ( GlgGraphLayout  graph,
GlgLong  index 
)

Finds an edge object by its index.

Parameters
graphGraph layout object.
indexEdge's index inside the graph's edge array.
Returns
The edge object.

◆ GlgGraphGetEdgeIndex()

GlgLong GlgGraphGetEdgeIndex ( GlgGraphLayout  graph,
GlgGraphEdge  edge 
)

Returns an edge's index inside the graph's edge_array.

Parameters
graphGraph layout object.
edgeThe edge object.
Returns
The edge's index or NULL if the edge is not in the node array.

◆ GlgGraphGetGroup()

GlgObject GlgGraphGetGroup ( GlgGraphLayout  graph)

Queries the container used to hold graph's nodes and edges.

Parameters
graphGraph layout object.
Returns
The group that holds graph's nodes and edges.

◆ GlgGraphGetNode()

GlgGraphNode GlgGraphGetNode ( GlgGraphLayout  graph,
GlgLong  index 
)

Finds a node object by its index.

Parameters
graphGraph layout object.
indexNode's index inside the graph's node array.
Returns
The node object.

◆ GlgGraphGetNodeIndex()

GlgLong GlgGraphGetNodeIndex ( GlgGraphLayout  graph,
GlgGraphNode  node 
)

Returns a node's index inside the graph's node array.

Parameters
graphGraph layout object.
nodeThe node object.
Returns
The node's index or NULL if the node is not in the node array.

◆ GlgGraphGetNodePosition()

void GlgGraphGetNodePosition ( GlgGraphLayout  graph,
GlgGraphNode  node,
double *  x,
double *  y,
double *  z 
)

Queries node position.

Parameters
graphGraph layout object.
nodeThe node to query.
x,y,zPointers that will receive X, Y and Z node position in the GLG world coordinates.

◆ GlgGraphGetUntangle()

GlgBoolean GlgGraphGetUntangle ( GlgGraphLayout  graph)

Queries if the untangling algorithm was enabled via GlgGraphSetUntangle.

The untangling algorithm helps the graph layout to avoid local minimums in the form of intersecting edges. Using it doubles the time it takes to finish the layout.

Parameters
graphGraph layout object.
Returns
True if the untangling algorithm is enabled.

◆ GlgGraphGetViewport()

GlgObject GlgGraphGetViewport ( GlgGraphLayout  graph)

Queries the viewport of the graph's drawing.

Parameters
graphGraph layout object.
Returns
The graph's viewport.

◆ GlgGraphIncreaseTemperature()

void GlgGraphIncreaseTemperature ( GlgGraphLayout  graph,
GlgBoolean  initial 
)

Forces the graph to continue layout after it's finished.

Parameters
graphGraph layout object.
initial
  • If True, increases "temperature" of the graph's nodes by a large increment.
  • If False, increases "temperature" of the graph's nodes by a small increment.

◆ GlgGraphNodesConnected()

GlgBoolean GlgGraphNodesConnected ( GlgGraphNode  node1,
GlgGraphNode  node2 
)

Connectivity test.

Parameters
node1The first node object.
node2The second node object.
Returns
True if there is an edge connecting the two nodes.

◆ GlgGraphScramble()

void GlgGraphScramble ( GlgGraphLayout  graph)

Demo function: Randomly scrambles the graph's nodes.

Parameters
graphGraph layout object.

◆ GlgGraphSetDefPalette()

void GlgGraphSetDefPalette ( GlgObject  palette_drawing)

Sets the default icon palette.

The default palette is used by all graph layouts if no graph-specific palette is defined to override the default one.

Parameters
palette_drawingPalette drawing object. See description of the GlgGraphSetPalette method for more details.

◆ GlgGraphSetNodePosition()

void GlgGraphSetNodePosition ( GlgGraphLayout  graph,
GlgGraphNode  node,
double  x,
double  y,
double  z 
)

Sets node position in the GLG world coordinates within the graph's dimensions.

The default dimensions are [-800; +800].

Parameters
graphGraph layout object.
nodeThe node to position.
xX coordinate.
yY coordinate.
zZ coordinate.

◆ GlgGraphSetPalette()

void GlgGraphSetPalette ( GlgGraphLayout  graph,
GlgObject  palette_drawing 
)

Sets a graph's icon palette.

Parameters
graphGraph layout object.
palette_drawingAn GLG object containing node and edge icons to be used for rendering the graph's nodes and edges.

The palette drawing must contain node icons named Node0, Node1, Node2 and so on. Each node icon must contain a data resource of the G (point) type named Position", which will be used by the graph layout to position the node. The palette must also contain an edge icon (a polygon object named Edge), which will be used to define the edges' attributes.

◆ GlgGraphSetUntangle()

void GlgGraphSetUntangle ( GlgGraphLayout  graph,
GlgBoolean  untangle 
)

Enables or disables untangling algorithm.

Parameters
graphGraph layout object.
untangleTrue to enable untangling, False to disable.

◆ GlgGraphSpringIterate()

GlgBoolean GlgGraphSpringIterate ( GlgGraphLayout  graph)

Performs one iteration of the spring embedder layout.

Parameters
graphGraph layout object.
Returns
True if the layout process has finished.

◆ GlgGraphUnloadDefPalette()

void GlgGraphUnloadDefPalette ( void  )

Unsets the default palette.

◆ GlgGraphUpdate()

void GlgGraphUpdate ( GlgGraphLayout  graph)

Updates the graphics display to show results of the spring layout.

There is no need to update the display after every iteration: it may be updated after every N iterations or just once, when the layout is finished.

If GlgGraphUpdateRate is set to a non-zero value, the GlgGraphSpringIterate function will periodically update the graph's graphics display, see GlgGraphUpdateRate.

Parameters
graphGraph layout object.