Documentation Center

  • Trial Software
  • Product Updates

biograph object

Data structure containing generic interconnected data used to implement directed graph

Description

A biograph object is a data structure containing generic interconnected data used to implement a directed graph. Nodes represent proteins, genes, or any other biological entity, and edges represent interactions, dependences, or any other relationship between the nodes. A biograph object also stores information, such as color properties and text label characteristics, used to create a 2-D visualization of the graph.

You create a biograph object using the object constructor function biograph. You can view a graphical representation of a biograph object using the view method.

Method Summary

Following are methods of a biograph object:

allshortestpaths (biograph)Find all shortest paths in biograph object
conncomp (biograph)Find strongly or weakly connected components in biograph object
dolayout (biograph)Calculate node positions and edge trajectories
get (biograph)Retrieve information about biograph object
getancestors (biograph)Find ancestors in biograph object
getdescendants (biograph)Find descendants in biograph object
getedgesbynodeid (biograph)Get handles to edges in biograph object
getmatrix (biograph)Get connection matrix from biograph object
getnodesbyid (biograph)Get handles to nodes
getrelatives (biograph)Find relatives in biograph object
isdag (biograph)Test for cycles in biograph object
isomorphism (biograph)Find isomorphism between two biograph objects
isspantree (biograph)Determine if tree created from biograph object is spanning tree
maxflow (biograph)Calculate maximum flow in biograph object
minspantree (biograph)Find minimal spanning tree in biograph object
set (biograph)Set property of biograph object
shortestpath (biograph)Solve shortest path problem in biograph object
topoorder (biograph)Perform topological sort of directed acyclic graph extracted from biograph object
traverse (biograph)Traverse biograph object by following adjacent nodes
view (biograph)Draw figure from biograph object

Following are methods of a node object:

getancestors (biograph)Find ancestors in biograph object
getdescendants (biograph)Find descendants in biograph object
getrelatives (biograph)Find relatives in biograph object

Property Summary

A biograph object contains two kinds of objects, node objects and edge objects, that have their own properties. For a list of the properties of node objects and edge objects, see the following tables.

Properties of a Biograph Object

PropertyDescription
IDString to identify the biograph object. Default is ''.
LabelString to label the biograph object. Default is ''.
DescriptionString that describes the biograph object. Default is ''.
LayoutType

String that specifies the algorithm for the layout engine. Choices are:

  • 'hierarchical' (default) — Uses a topological order of the graph to assign levels, and then arranges the nodes from top to bottom, while minimizing crossing edges.

  • 'radial' — Uses a topological order of the graph to assign levels, and then arranges the nodes from inside to outside of the circle, while minimizing crossing edges.

  • 'equilibrium' — Calculates layout by minimizing the energy in a dynamic spring system.

EdgeType

String that specifies how edges display. Choices are:

  • 'straight'

  • 'curved' (default)

  • 'segmented'

    Note:   Curved or segmented edges occur only when necessary to avoid obstruction by nodes. Biograph objects with LayoutType equal to 'equilibrium' or 'radial' cannot produce curved or segmented edges.

Scale Positive number that post-scales the node coordinates. Default is 1.
LayoutScalePositive number that scales the size of the nodes before calling the layout engine. Default is 1.
EdgeTextColorThree-element numeric vector of RGB values. Default is [0, 0, 0], which defines black.
EdgeFontSizePositive number that sets the size of the edge font in points. Default is 8.
ShowArrowsControls the display of arrows with the edges. Choices are 'on' (default) or 'off'.
ArrowSizePositive number that sets the size of the arrows in points. Default is 8.
ShowWeightsControls the display of text indicating the weight of the edges. Choices are 'on' (default) or 'off'.
ShowTextInNodes

String that specifies the node property used to label nodes when you display a biograph object using the view method. Choices are:

  • 'Label' — Uses the Label property of the node object (default).

  • 'ID' — Uses the ID property of the node object.

  • 'None'

NodeAutoSizeControls precalculating the node size before calling the layout engine. Choices are 'on' (default) or 'off'.

    Note:   Set it to off if you want to apply different node sizes by changing the Size property.

NodeCallbackUser-defined callback for all nodes. Enter the name of a function, a function handle, or a cell array with multiple function handles. After using the view function to display the biograph object in the Biograph Viewer, you can double-click a node to activate the first callback, or right-click and select a callback to activate. Default is the anonymous function, @(node) inspect(node), which displays the Property Inspector dialog box.
EdgeCallbackUser-defined callback for all edges. Enter the name of a function, a function handle, or a cell array with multiple function handles. After using the view function to display the biograph object in the Biograph Viewer, you can double-click an edge to activate the first callback, or right-click and select a callback to activate. Default is the anonymous function, @(edge) inspect(edge), which displays the Property Inspector dialog box.
CustomNodeDrawFcnFunction handle to a customized function to draw nodes. Default is [].
NodesRead-only column vector with handles to node objects of a biograph object. The size of the vector is the number of nodes. For properties of node objects, see Properties of a Node Object.
EdgesRead-only column vector with handles to edge objects of a biograph object. The size of the vector is the number of edges. For properties of edge objects, see Properties of an Edge Object.

Properties of a Node Object

PropertyDescription
IDCharacter string defined when the biograph object is created, either by the NodeIDs input argument or internally by the biograph constructor function. You can modify this property using the set method, but each node object's ID must be unique.
LabelString for labeling a node when you display a biograph object using the view method. Default is ''.
DescriptionString that describes the node. Default is ''.
PositionTwo-element numeric vector of x- and y-coordinates, for example, [150, 150]. If you do not specify this property, default is initially [], then when the layout algorithms are executed, it becomes a two-element numeric vector of x- and y-coordinates computed by the layout engine.
Shape

String that specifies the shape of the nodes. Choices are:

  • 'box'(default)

  • 'ellipse'

  • 'circle'

  • 'rectangle'

  • 'diamond'

  • 'trapezium'

  • 'invtrapezium'

  • 'house'

  • 'inverse'

  • 'parallelogram'

SizeTwo-element numeric vector calculated before calling the layout engine using the actual font size and shape of the node. Default is [10, 10].
ColorThree-element numeric vector of RGB values that specifies the fill color of the node. Default is [1, 1, 0.7], which defines yellow.
LineWidthPositive number. Default is 1.
LineColorThree-element numeric vector of RGB values that specifies the outline color of the node. Default is [0.3, 0.3, 1], which defines blue.
FontSizePositive number that sets the size of the node font in points. Default is 8.
TextColorThree-element numeric vector of RGB values that specifies the color of the node labels. Default is [0, 0, 0], which defines black.
UserDataMiscellaneous, user-defined data that you want to associate with the node. The node does not use this property, but you can access and specify it using the get and set functions. Default is [].

Properties of an Edge Object

PropertyDescription
IDCharacter string automatically generated from the node IDs when the biograph object is created by the biograph constructor function. You can modify this property using the set method, but each edge object's ID must be unique.
LabelString for labeling an edge. Default is ''.
DescriptionString that describes the edge. Default is ''.
WeightValue that represents the weight (cost, distance, length, or capacity) associated with the edge. Default is 1.
LineWidthPositive number. Default is 1.
LineColorThree-element numeric vector of RGB values that specifies the color of the edge. Default is [0.5, 0.5, 0.5], which defines gray.
UserDataMiscellaneous, user-defined data that you want to associate with the edge. The edge does not use this property, but you can access and specify it using the get and set functions. Default is [].

Examples

expand all

Create a Biograph object, specify and access its properties

This example shows how to create a biograph object, access and update its properties.

Create a biograph object with custom node IDs.

cm = [0 1 1 0 0;1 0 0 1 1;1 0 0 0 0;0 0 0 0 1;1 0 1 0 0];
ids = {'M30931','L07625','K03454','M27323','M15390'};
bg1 = biograph(cm,ids)
Biograph object with 5 nodes and 9 edges.

Specify the ID property of the object.

set(bg1,'ID','mybg')
get(bg1,'ID')
ans =

mybg

Use the get function to display the node IDs.

get(bg1.nodes,'ID')
ans = 

    'M30931'
    'L07625'
    'K03454'
    'M27323'
    'M15390'

Display all properties and their current values of the 5th node and 5th edge of the object.

get(bg1.nodes(5))
             ID: 'M15390'
          Label: ''
    Description: ''
       Position: []
          Shape: 'box'
           Size: [10 10]
          Color: [1 1 0.7000]
      LineWidth: 1
      LineColor: [0.3000 0.3000 1]
       FontSize: 9
      TextColor: [0 0 0]
       UserData: []

get(bg1.edges(5))
             ID: 'L07625 -> M15390'
          Label: ''
    Description: ''
         Weight: 1
      LineWidth: 0.5000
      LineColor: [0.5000 0.5000 0.5000]
       UserData: []

Set the LineWidth property of the 5th node to 2.

set(bg1.nodes(5),'LineWidth',2.0)
bg1.nodes(5)
             ID: 'M15390'
          Label: ''
    Description: ''
       Position: []
          Shape: 'box'
           Size: [10 10]
          Color: [1 1 0.7000]
      LineWidth: 2
      LineColor: [0.3000 0.3000 1]
       FontSize: 9
      TextColor: [0 0 0]
       UserData: []

Alternatively use getnodesbyid function to create a handle for the 5th node, and specify its Shape property (or any other properties).

nh1 = getnodesbyid(bg1,'M15390')
             ID: 'M15390'
          Label: ''
    Description: ''
       Position: []
          Shape: 'box'
           Size: [10 10]
          Color: [1 1 0.7000]
      LineWidth: 2
      LineColor: [0.3000 0.3000 1]
       FontSize: 9
      TextColor: [0 0 0]
       UserData: []

set(nh1,'Shape','circle')
nh1
             ID: 'M15390'
          Label: ''
    Description: ''
       Position: []
          Shape: 'circle'
           Size: [10 10]
          Color: [1 1 0.7000]
      LineWidth: 2
      LineColor: [0.3000 0.3000 1]
       FontSize: 9
      TextColor: [0 0 0]
       UserData: []

Specify the LineColor property of the 5th edge.

set(bg1.edges(5),'LineColor',[0.7 0.0 0.1])
bg1.edges(5)
             ID: 'L07625 -> M15390'
          Label: ''
    Description: ''
         Weight: 1
      LineWidth: 0.5000
      LineColor: [0.7000 0 0.1000]
       UserData: []

Alternatively use getedgesbynodeid to retrieve the handel to the edge by providing a source node id and a sink node id.

eh1 = getedgesbynodeid(bg1,'L07625','M15390')
             ID: 'L07625 -> M15390'
          Label: ''
    Description: ''
         Weight: 1
      LineWidth: 0.5000
      LineColor: [0.7000 0 0.1000]
       UserData: []

Use the handle to specify the LineWidth property or any other properties of the edge.

set(eh1,'LineWidth',2.0)
eh1
             ID: 'L07625 -> M15390'
          Label: ''
    Description: ''
         Weight: 1
      LineWidth: 2
      LineColor: [0.7000 0 0.1000]
       UserData: []

View the biograph object.

view(bg1)

See Also

| | | | | | | | | | | | | | | | | | | |

Was this topic helpful?