Main Content

show

Plot graph representation

Since R2023a

    Description

    example

    show(graph) plots the graph representation.

    show(graph,Parent=ax) specifies the axes on which to plot the graph representation.

    axHandle = show(___) returns the axes handle of the graph representation plot, in addition to any combination of input arguments from previous syntaxes.

    Examples

    collapse all

    Load data for states and links.

    load navGraphData.mat

    Create state and link tables.

    stateTable = table(data.states,data.names,data.numLanes, ...
        VariableNames=["StateVector","Name","Lanes"]);
    linkTable = table(data.links,data.linkWt,data.curvature, ...
        VariableNames=["EndStates","Weight","Curvature"]);

    Create a navGraph object from the state and link tables.

    graphObj = navGraph(stateTable,linkTable);

    Create a deep copy of the navGraph object.

    graph2 = copy(graphObj)
    graph2 = 
      navGraph with properties:
    
               States: [8x3 table]
                Links: [7x3 table]
        LinkWeightFcn: @nav.algs.distanceEuclidean
    
    

    Visualize the navGraph object.

    show(graphObj)

    Find the link IDs of two state pairs. The function returns the link ID for the state pair ["G","A"]. However, it returns 0 as the link ID for the state pair ["C","D"] as the link does not exist in the navGraph object.

    linkIDS = findlink(navGraphObj,["G","A"; "C","D"])
    linkIDS = 2×1
    
         5
         0
    
    

    Input Arguments

    collapse all

    Graph object, specified as a navGraph object.

    Example: show(graph)

    Example: axHandle = show(graph);

    Axes on which to plot the graph representation, specified as an Axes object.

    Example: show(graph,Parent=ax)

    Example: axHandle = show(graph,Parent=ax);

    Output Arguments

    collapse all

    Axes handle of the graph representation plot, returned as an Axes object.

    Version History

    Introduced in R2023a