Main Content

copy

Create deep copy of navGraph object

Since R2023a

    Description

    graph2 = copy(graph1) creates a deep copy of a navGraph object.

    example

    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)

    Figure contains an axes object. The axes object contains an object of type graphplot.

    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: graphcopy = copy(graph)

    Output Arguments

    collapse all

    Copy of a graph object, returned as a navGraph object.

    Extended Capabilities

    C/C++ Code Generation
    Generate C and C++ code using MATLAB® Coder™.

    Version History

    Introduced in R2023a