This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

getancestors (biograph)

Find ancestors of a node in biograph object


Node = getancestors(BiographNode)
Node = getancestors(BiographNode, NumGenerations)



Node in a biograph object.


Number of generations. Enter a positive integer.


Node = getancestors(BiographNode) returns a node (BiographNode) and all of its direct ancestors.

Node = getancestors(BiographNode, NumGenerations) finds the node (BiographNode) and its direct ancestors up to a specified number of generations (NumGenerations). If NumGenerations is 0, the function returns the node itself.


  1. Create a biograph object.

    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];
    bg = biograph(cm)
  2. Find one generation of ancestors for node 2.

    ancNodes = getancestors(bg.nodes(2));
    set(ancNodes,'Color',[1 .7 .7]);

  3. Find two generations of ancestors for node 2.

    ancNodes = getancestors(bg.nodes(2),2);
    set(ancNodes,'Color',[.7 1 .7]);

Introduced before R2006a

Was this topic helpful?