Documentation Center

  • Trial Software
  • Product Updates

biograph

Create biograph object

Syntax

BGobj = biograph(CMatrix)
BGobj = biograph(CMatrix, NodeIDs)

BGobj = biograph(CMatrix, NodeIDs, ...'ID', IDValue, ...)
BGobj = biograph(CMatrix, NodeIDs, ...'Label', LabelValue, ...)
BGobj = biograph(CMatrix, NodeIDs, ...'Description', DescriptionValue, ...)
BGobj = biograph(CMatrix, NodeIDs, ...'LayoutType', LayoutTypeValue, ...)
BGobj = biograph(CMatrix, NodeIDs, ...'EdgeType', EdgeTypeValue, ...)
BGobj = biograph(CMatrix, NodeIDs, ...'Scale', ScaleValue, ...)
BGobj = biograph(CMatrix, NodeIDs, ...'LayoutScale', LayoutScaleValue, ...)
BGobj = biograph(CMatrix, NodeIDs, ...'EdgeTextColor', EdgeTextColorValue, ...)
BGobj = biograph(CMatrix, NodeIDs, ...'EdgeFontSize', EdgeFontSizeValue, ...)
BGobj = biograph(CMatrix, NodeIDs, ...'ShowArrows', ShowArrowsValue, ...)
BGobj = biograph(CMatrix, NodeIDs, ...'ArrowSize', ArrowSizeValue, ...)
BGobj = biograph(CMatrix, NodeIDs, ...'ShowWeights', ShowWeightsValue, ...)
BGobj = biograph(CMatrix, NodeIDs, ...'ShowTextInNodes', ShowTextInNodesValue, ...)
BGobj = biograph(CMatrix, NodeIDs, ...'NodeAutoSize', NodeAutoSizeValue, ...)
BGobj = biograph(CMatrix, NodeIDs, ...'NodeCallback', NodeCallbackValue, ...)
BGobj = biograph(CMatrix, NodeIDs, ...'EdgeCallback', EdgeCallbackValue, ...)
BGobj = biograph(CMatrix, NodeIDs, ...'CustomNodeDrawFcn', CustomNodeDrawFcnValue, ...)

Arguments

CMatrixFull or sparse square matrix that acts as a connection matrix. That is, a value of 1 indicates a connection between nodes while a 0 indicates no connection. The number of rows/columns is equal to the number of nodes.
NodeIDs

Node identification strings. Enter any of the following:

  • Cell array of strings with the number of strings equal to the number of rows or columns in the connection matrix CMatrix. Each string must be unique.

  • Character array with the number of rows equal to the number of nodes. Each row in the array must be unique.

  • String with the number of characters equal to the number of nodes. Each character must be unique.

Default values are the row or column numbers.

    Note:   You must specify NodeIDs if you want to specify property name/value pairs. Set NodeIDs to [] to use the default values of the row/column numbers.

IDValueString to identify the biograph object. Default is ''.
LabelValueString to label the biograph object. Default is ''.
DescriptionValueString that describes the biograph object. Default is ''.
LayoutTypeValue

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.

EdgeTypeValue

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.

ScaleValuePositive number that post-scales the node coordinates. Default is 1.
LayoutScaleValuePositive number that scales the size of the nodes before calling the layout engine. Default is 1.
EdgeTextColorValueThree-element numeric vector of RGB values. Default is [0, 0, 0], which defines black.
EdgeFontSizeValuePositive number that sets the size of the edge font in points. Default is 8.
ShowArrowsValueControls the display of arrows for the edges. Choices are 'on' (default) or 'off'.
ArrowSizeValuePositive number that sets the size of the arrows in points. Default is 8.
ShowWeightsValueControls the display of text indicating the weight of the edges. Choices are 'on' (default) or 'off'.
ShowTextInNodesValue

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'

NodeAutoSizeValueControls 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.

NodeCallbackValueUser 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 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 @(node) inspect(node), which displays the Property Inspector dialog box.
EdgeCallbackValueUser 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 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 @(edge) inspect(edge), which displays the Property Inspector dialog box.
CustomNodeDrawFcnValueFunction handle to a customized function to draw nodes. Default is [].

Description

BGobj = biograph(CMatrix) creates a biograph object, BGobj, using a connection matrix, CMatrix. All nondiagonal and positive entries in the connection matrix, CMatrix, indicate connected nodes, rows represent the source nodes, and columns represent the sink nodes.

BGobj = biograph(CMatrix, NodeIDs) specifies the node identification strings. NodeIDs can be:

  • Cell array of strings with the number of strings equal to the number of rows or columns in the connection matrix CMatrix. Each string must be unique.

  • Character array with the number of rows equal to the number of nodes. Each row in the array must be unique.

  • String with the number of characters equal to the number of nodes. Each character must be unique.

Default values are the row or column numbers.

    Note:   If you want to specify property name/value pairs, you must specify NodeIDs. Set NodeIDs to [] to use the default values of the row/column numbers.

BGobj = biograph(..., 'PropertyName', PropertyValue, ...) calls biograph with optional properties that use property name/property value pairs. You can specify one or more properties in any order. Each PropertyName must be enclosed in single quotation marks and is case insensitive. These property name/property value pairs are as follows:


BGobj = biograph(CMatrix, NodeIDs, ...'ID', IDValue, ...)
specifies an ID for the biograph object. Default is ''.

BGobj = biograph(CMatrix, NodeIDs, ...'Label', LabelValue, ...) specifies a label for the biograph object. Default is ''.

BGobj = biograph(CMatrix, NodeIDs, ...'Description', DescriptionValue, ...) specifies a description of the biograph object. Default is ''.

BGobj = biograph(CMatrix, NodeIDs, ...'LayoutType', LayoutTypeValue, ...) specifies the algorithm for the layout engine.

BGobj = biograph(CMatrix, NodeIDs, ...'EdgeType', EdgeTypeValue, ...) specifies how edges display.

BGobj = biograph(CMatrix, NodeIDs, ...'Scale', ScaleValue, ...) post-scales the node coordinates. Default is 1.

BGobj = biograph(CMatrix, NodeIDs, ...'LayoutScale', LayoutScaleValue, ...) scales the size of the nodes before calling the layout engine. Default is 1.

BGobj = biograph(CMatrix, NodeIDs, ...'EdgeTextColor', EdgeTextColorValue, ...) specifies a three-element numeric vector of RGB values. Default is [0, 0, 0], which defines black.

BGobj = biograph(CMatrix, NodeIDs, ...'EdgeFontSize', EdgeFontSizeValue, ...) sets the size of the edge font in points. Default is 8.

BGobj = biograph(CMatrix, NodeIDs, ...'ShowArrows', ShowArrowsValue, ...) controls the display of arrows for the edges. Choices are 'on' (default) or 'off'.

BGobj = biograph(CMatrix, NodeIDs, ...'ArrowSize', ArrowSizeValue, ...) sets the size of the arrows in points. Default is 8.

BGobj = biograph(CMatrix, NodeIDs, ...'ShowWeights', ShowWeightsValue, ...) controls the display of text indicating the weight of the edges. Choices are 'on' (default) or 'off'.

BGobj = biograph(CMatrix, NodeIDs, ...'ShowTextInNodes', ShowTextInNodesValue, ...) specifies the node property used to label nodes when you display a biograph object using the view method.

BGobj = biograph(CMatrix, NodeIDs, ...'NodeAutoSize', NodeAutoSizeValue, ...) controls precalculating the node size before calling the layout engine. Choices are 'on' (default) or 'off'.

BGobj = biograph(CMatrix, NodeIDs, ...'NodeCallback', NodeCallbackValue, ...) specifies user callback for all nodes.

BGobj = biograph(CMatrix, NodeIDs, ...'EdgeCallback', EdgeCallbackValue, ...) specifies user callback for all edges.

BGobj = biograph(CMatrix, NodeIDs, ...'CustomNodeDrawFcn', CustomNodeDrawFcnValue, ...) specifies function handle to customized function to draw nodes. Default is [].

Examples

expand all

Create a biograph object

This example shows how to create a biograph object.

Create a biograph object with default node IDs, and then use the get function to display the 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];
bg1 = biograph(cm)
Biograph object with 5 nodes and 9 edges.
get(bg1.nodes,'ID')
ans = 

    'Node 1'
    'Node 2'
    'Node 3'
    'Node 4'
    'Node 5'

Create a biograph object, assign the node IDs, and then use the get function to display the 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'};
bg2 = biograph(cm,ids);
get(bg2.nodes,'ID')
ans = 

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

Display the biograph object.

view(bg2)

More About

See Also

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

Was this topic helpful?