D4L / abstractGraph

MIT License
2 stars 0 forks source link

Add Vertex Adjacency #9

Closed D4L closed 11 years ago

D4L commented 11 years ago

Vertex Adjacency

Task

Allow users to ask a vertex what it's adjacent to. In other words, which other vertices it is connected by an edge with.

Content

Assume graph is the 4-cycle ( { v1, v2, v4, v8 }, { edges formed with sum (e##) } )

graph.is_adjacent?( "v1", "v2" ) # => true
graph.is_adjacent?( "v1", "v4" ) # => false
graph.adjacency_list "v4"        # => [ "v2", "v8" ]