Table of Contents
This chapter presents first steps to using the algorithms graph structure of yFiles FLEX Client Layout Extension and outlines general programming aspects. It explains technical consequences of some of the concepts in more detail. Also, it introduces well-known graph analyzing algorithms indispensable to the serious graph worker.
Class Graph offers three constructors, one to create an empty graph, i.e., one where node and edge set are empty, the other two to create new instances which are either partial or complete copies of an already existing graph.
// Create a new, empty graph. var graph:Graph = new Graph(); // Create a complete copy of 'graph'. var graphCopy:Graph = Graph.newGraph2(graph);
It is also possible to ask an instance of type Graph to create a complete copy of itself or to create a new empty graph instance.
When populating an existing graph with graph elements, it is important to observe certain preconditions:
// 'graph' is of type com.yworks.yfiles.base.Graph. // Create 10 nodes. var n:Array = new Array(10); for (var i:int = 0; i < 10; i++) { n[i] = graph.createNode(); } // Create 5 edges. Each edge has "even" source node and "odd" target node. var e:Array = new Array(5); for (var i:int = 0, j:int = 0; i < 10; i += 2, j++) { e[j] = graph.createEdge(n[i], n[i + 1]); }
Note that the code snippets presented in the course of this document serve as examples to demonstrate how to use the functionality yFiles provides. Although they are all correct, they are not complete and will most likely not compile when copied directly.
Copyright ©2010-2015, yWorks GmbH. All rights reserved. |