Create Shortest Path Feature Task


The purpose of this sample is to create a new polyline feature that correspond to the Shortest Path between the two input points. The sample is using the Dijkstra algorithm with a weight corresponding to the Euclidian distance between nodes of the graph. The Planar Graph used here is the Topology Graph.

How to use:
  1. Register the dll on your machine.
  2. Use Categories to add the dll to the 'ESRI Edit Tasks' component category.
  3. Make sure you have either a Geodatabase Topology or a Map Topology (if not then please build one) present in the map document
  4. Start an edit session and select the Create Shortest Path Feature task
  5. Set the Current Layer to a polyline feature class.
  6. Using the sketch tool create two points that correspond to the Start and End Point from which the shortest will be calculated.
  7. Finish the sketch, a TopologyGraph will be built and the shortest path feature will be created in the output feature class.


Requires: An edit session, a 8.3 Geodatabase Topology or a 8.3 Map Topology, a polyline feature class that will be used as ouput.

Minimum ArcGIS Version Required: 8.3

Difficulty: Advance

Visual Basic
File Description
ShortestPath.cls Class implementing the edit task.
adjNode.cls Custom object.
node.cls Custom object.
ShortestPath.vbp The project file for the custom edit task.
ShortestPath.dll The compiled project.

Key CoClasses: Editor
Key Interfaces: IEditTask, IEditSketch, ITopologyExtension, ITopology, IMapTopology, ITopologyGraph, IEnumNodeEdge
Key Members: IEditSketch::Geometry, ITopologyGraph::Build, ITopologyGraph::HitTest, ITopologyGraph::Select, ITopologyGraph::BuildExtent, ITopologyNode::IsDegreeKnown, IEnumNodeEdge::Next, ITopologyExtension::CurrentTopology