terra-route-graph
    Preparing search index...

    terra-route-graph

    Terra Draw logo

    Terra Route Graph is a helper class to Terra Route (a fast shortest path finding library). It provides functionality for better understanding your graphs that you use with Terra Route.

    npm install terra-route-graph
    

    API Docs can be found here

    TerraRouteGraph main use case is for for analyzing GeoJSON route networks. This class is especially useful for debugging, as it includes methods to identify unique nodes, edges, and connected components, along with their counts. Beyond debugging, these methods help you programmatically explore and understand the structure of your graph — for example, by measuring its size and examining how its parts are connected.

    const graph = new TerraDrawGraph(network);

    // Return all nodes in the graph as FeatureCollection<Point>, where each unique node is a Feature<Point>
    const graphPoints = graph.getNodes();

    // Return all the unique edges as FeatureCollection<LineString>, where each unique edge is a Feature<LineString>
    const graphEdges = graph.getEdges();

    MIT