documentationfor yFiles for HTML 2.6

Creating a Graph from Business Data

The yFiles for HTML data binding module provides a convenient way of creating a graph structure from business data. It is tailored to specific use cases where a tree or general graph structure can be easily derived from a data model that meets certain conditions.

Along with the creation of the graph structure, the yFiles for HTML data binding module also enables specifying both the visual representation of nodes and edges in the graph and the hierarchical organization in a grouped graph. There is no layout algorithm applied once a graph is built. However, this can be easily done in a subsequent step.

The yFiles for HTML package contains a multistep code tutorial on how to use the data binding module, starting with the first step: Creating a graph from business data.

Even if a data model does not fit the specific use cases that the data binding classes are tailored to, the graph builders might still be of use to accomplish an initial import of at least a part of the data model, for example the nodes.Please keep in mind that in this case it might be easier to abstain from using the graph builders and create the graph the “regular way,” that is, by building and populating a graph structure using the functionality provided by the default IGraph implementation.

The yFiles for HTML data binding module covers some of the most common ways of creating graph structures from business data. Since each use case has its own specifics, there are several different graph builder classes, each tailored for a specific set of structure of the input data and the desired graph features.

When choosing a data binding class, a simple criterion is whether the data has a tree structure. In this case, the TreeBuilder class can be used. Of course, all classes for general graphs can be used for trees as well. AdjacencyGraphBuilder is an even more general version of TreeBuilder.

If the business data does not describe a tree structure but a general graph, GraphBuilder or AdjacencyGraphBuilder can be chosen based on the way the connections between nodes are specified in the data model. The following table gives a more detailed description of the data models required by each class:

Data binding classes
Type Name Graph Structure Description
TreeBuilderTreeCreates a tree from a tree-structured data model without explicit objects for edges. Each business object specifies its child objects and thereby edges are defined implicitly. The TreeBuilder does not support specifying children indirectly via ids. If the data model specifies the children of a node via id references, the AdjacencyGraphBuilder can be used instead. See more details below.
GraphBuilderGeneralCreates a general graph from a data model which provides business objects for both nodes and edges. The collection of nodes and the collection of edges are specified separately. Supports binding data to an edge’s label and also multiple edges between the same pair of node objects. See more details below.
AdjacencyGraphBuilderGeneralCreates a general graph from a data model without an explicit collection for edges. Each business object specifies the objects in its neighborhood and thus implicitly its incident edges. A node’s neighborhood may either directly specify its neighbor nodes or specify its neighbor edges as separate objects, which point to the respective other node. See more details below.

App Generator

The App Generator is an ETL tool that lets you rapidly prototype yFiles for HTML applications with custom data, styling and graph layout.

As the App Generator uses the GraphBuilder and related classes for building an application, it is also a very good tool to learn the interdependencies of them in an explorative manner.