dominikbraun / graph

A library for creating generic graph data structures and modifying, analyzing, and visualizing them.
https://graph.dominikbraun.io
Apache License 2.0
1.81k stars 94 forks source link

Feature: Add method for querying toVertex/fromVertex and steps #174

Open kcmvp opened 5 months ago

kcmvp commented 5 months ago

right now I haave two cases, which dont have simple way to ahieve 1: query all the direct vertexs( from vertexes) to a specified Vertex 2: query all the direct vertexes(target Vertexs) from a specified Vertex.

there may be similar requirements for different steps, so hope it supplies two method

1: Vertexes.To(hash K, steps int) []Vertex 1: Vertexes.From(hash K, steps int) []Vertex

davemcphee commented 4 months ago

It sounds like PredecessorMap and AdjacencyMap already do this. Both return a map[K]map[K]Edge[K] of incoming (for PredecessorMap) and outgoing (for AdjacencyMap) Edges.

Edges have a Source and Target, so you can grab the corresponding Vertices from the Graph using either of those.