Class: RGL::BidirectionalAdjacencyGraph
Overview
Instance Method Summary
collapse
#degree
Methods included from Graph
#acyclic?, #adjacent_vertices, #bellman_ford_shortest_paths, #bfs_iterator, #bfs_search_tree_from, #bipartite?, #bipartite_sets, #condensation_graph, #depth_first_search, #depth_first_visit, #dfs_iterator, #dijkstra_shortest_path, #dijkstra_shortest_paths, #directed?, #dotty, #each, #each_adjacent, #each_connected_component, #each_edge, #each_vertex, #edge_class, #edges, #edges_filtered_by, #empty?, #eql?, #has_edge?, #has_vertex?, #implicit_graph, #maximum_flow, #num_edges, #out_degree, #path?, #prim_minimum_spanning_tree, #print_dotted_on, #reverse, #set_edge_options, #set_vertex_options, #size, #strongly_connected_components, #to_adjacency, #to_dot_graph, #to_s, #to_undirected, #topsort_iterator, #transitive_closure, #transitive_reduction, #vertex_id, #vertex_label, #vertices, #vertices_filtered_by, #write_to_graphic_file
[], #directed?, #each_adjacent, #each_vertex, #edgelist_class=, #has_edge?, #has_vertex?, #initialize_copy
#add_edges, #add_vertices, #cycles, #cycles_with_vertex, #from_graphxml, #remove_vertices
Constructor Details
In super method the in edges are also added since #add_edge of this class also inserts edges in ‘@reverse`.
20
21
22
23
|
# File 'lib/rgl/bidirectional_adjacency.rb', line 20
def initialize(edgelist_class = Set, *other_graphs)
@reverse = DirectedAdjacencyGraph.new(edgelist_class)
super(edgelist_class, *other_graphs)
end
|
Instance Method Details
#add_edge(u, v) ⇒ Object
32
33
34
35
|
# File 'lib/rgl/bidirectional_adjacency.rb', line 32
def add_edge(u, v)
super(u, v)
@reverse.add_edge(v, u)
end
|
#add_vertex(v) ⇒ Object
26
27
28
29
|
# File 'lib/rgl/bidirectional_adjacency.rb', line 26
def add_vertex(v)
super(v)
@reverse.add_vertex(v)
end
|
#each_in_neighbor(v, &b) ⇒ Object
57
58
59
|
# File 'lib/rgl/bidirectional_adjacency.rb', line 57
def each_in_neighbor(v, &b)
@reverse.each_adjacent(v, &b)
end
|
#has_in_edge?(u, v) ⇒ Boolean
50
51
52
|
# File 'lib/rgl/bidirectional_adjacency.rb', line 50
def has_in_edge?(u, v)
@reverse.has_edge?(u, v)
end
|
#in_degree(v) ⇒ int
Returns the number of in-edges (for directed graphs) or the number of incident edges (for undirected graphs) of vertex v.
70
71
72
|
# File 'lib/rgl/bidirectional_adjacency.rb', line 70
def in_degree(v)
@reverse.out_degree(v)
end
|
#in_neighbors(v) ⇒ Object
63
64
65
|
# File 'lib/rgl/bidirectional_adjacency.rb', line 63
def in_neighbors(v)
@reverse.adjacent_vertices(v)
end
|
#remove_edge(u, v) ⇒ Object
44
45
46
47
|
# File 'lib/rgl/bidirectional_adjacency.rb', line 44
def remove_edge(u, v)
super(u, v)
@reverse.remove_edge(v, u)
end
|
#remove_vertex(v) ⇒ Object
38
39
40
41
|
# File 'lib/rgl/bidirectional_adjacency.rb', line 38
def remove_vertex(v)
super(v)
@reverse.remove_vertex(v)
end
|