Skip to main content

shortestPath()

shortestPath returns an array of IDs of nodes on the shortest path between source and target.

Learn more about the shortestPath plugin.

graphUtils.shortestPath(
graph: dia.Graph,
source: dia.Element | string | number,
target: dia.Element | string | number,
opt?: ShortestPathOptions
): Array<string | number>;

Returns an array of IDs of nodes on the shortest path between source and target.

Types

ShortestPathOptions

interface ShortestPathOptions {
directed?: boolean;
weight?: (id1: string, id2: string) => number;
}

Stay in the know

Be where thousands of diagramming enthusiasts meet

Star us on GitHub