Main Content

rmlink

Remove links between one or more state pairs

Since R2024a

Description

rmlink(graph,linkIDs) removes the state pairs specified by the link identifiers from the input graph.

example

rmlink(graph,statePairs) removes the state pairs specified by the state indices or state names from the input graph.

example

Examples

collapse all

Load navGraph object into MATLAB® workspace and inspect its properties.

load("navGraphData.mat")
disp(navGraphObj)
  navGraph with properties:

           States: [8x3 table]
            Links: [7x3 table]
    LinkWeightFcn: @nav.algs.distanceEuclidean

Inspect the links table of the input graph.

disp(navGraphObj.Links)
    EndStates    Weight    Curvature
    _________    ______    _________

     1    3      1.5089    0.0034635
     3    7       8.921    0.0063649
     5    4       2.387    0.0060558
     6    2      19.452    0.0041751
     7    1      38.776    0.0051347
     7    8      13.938    0.0076324
     8    2      43.893    0.0031493

Display the input graph.

show(navGraphObj)

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

Specify Link Identifiers to Unlink State Pairs

Specify the indices of the state pairs you want to remove from the links table. In this example, you will remove linking between the state pairs defined in the first and third rows of the links table.

rmlink(navGraphObj,[1;3])

Inspect the updated links table for the unlinked state pairs and display the updated graph.

disp(navGraphObj.Links)
    EndStates    Weight    Curvature
    _________    ______    _________

     3    7       8.921    0.0063649
     6    2      19.452    0.0041751
     7    1      38.776    0.0051347
     7    8      13.938    0.0076324
     8    2      43.893    0.0031493

Display the updated graph.

show(navGraphObj)

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

Specify State Indices to Unlink Multiple State Pairs

Specify the indices of the linked states in the states table that you want to disconnect.

rmlink(navGraphObj,[3 7;6 2;7 1])

Inspect the updated links table for the state pairs that are disconnected.

disp(navGraphObj.Links)
    EndStates    Weight    Curvature
    _________    ______    _________

     7    8      13.938    0.0076324
     8    2      43.893    0.0031493

Display the updated graph.

show(navGraphObj)

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

Input Arguments

collapse all

Graph object, specified as a navGraph object.

Link identifiers, specified as a column vector of positive integers. Link identifiers represent the indices of the state pairs in the links table of the graph.

Indices of the states that are connected, specified as a two-element column vector or M-by-2 matrix. The indices of the connected states must be taken from the states table or the links table of the input navGraph object. The first column of the links table specify the indices of the connected state pairs. For example, when you specify statePairs as [1 3], the function unlinks the states listed in the first and third rows of the states table of the input graph.

M specifies the number of connected state pairs to be unlinked.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | string | cell

Extended Capabilities

Version History

Introduced in R2024a