Module: Silicium::GraphVisualizer
- Includes:
- Ruby2D, Graphs
- Defined in:
- lib/graph_visualizer.rb
Constant Summary collapse
- @@vert_radius =
radius of vertices circles
15
- @@line_width =
width of the edges
5
- @@label_size =
size of labels
15
- @@label_color =
color of labels
Color.new('red')
- @@vertex_color =
color of vertices
Color.new('white')
Instance Method Summary collapse
-
#change_edge_width(w) ⇒ Object
Changes width of edges.
-
#change_label_color(c) ⇒ Object
Changes labels color.
-
#change_label_size(s) ⇒ Object
Changes labels size.
-
#change_vertex_color(c) ⇒ Object
Changes vertices color.
-
#change_vertices_radius(r) ⇒ Object
Changes radius of vertices.
-
#change_window_size(w, h) ⇒ Object
Changes window size.
-
#clear_window ⇒ Object
clear screen.
-
#close_window ⇒ Object
close screen.
-
#set_graph(graph) ⇒ Object
Set the graph for visualization.
-
#show_window ⇒ Object
show graph on the screen.
Methods included from Graphs
#add_edge!, #add_to_queue, #add_to_stack, #breadth_first_search?, #connected?, #depth_first_search?, #dfs_traverse, #dfs_traverse_recursive, #dfu, #dijkstra_algorithm, #goal_node?, #graph_to_sets, #kruskal_mst, #number_of_connected, #sum_labels
Instance Method Details
#change_edge_width(w) ⇒ Object
Changes width of edges
18 19 20 |
# File 'lib/graph_visualizer.rb', line 18 def change_edge_width(w) @@line_width = w end |
#change_label_color(c) ⇒ Object
Changes labels color
36 37 38 |
# File 'lib/graph_visualizer.rb', line 36 def change_label_color(c) @@label_color = Color.new(c) end |
#change_label_size(s) ⇒ Object
Changes labels size
30 31 32 |
# File 'lib/graph_visualizer.rb', line 30 def change_label_size(s) @@label_size = s end |
#change_vertex_color(c) ⇒ Object
Changes vertices color
42 43 44 |
# File 'lib/graph_visualizer.rb', line 42 def change_vertex_color(c) @@vertex_color = Color.new(c) end |
#change_vertices_radius(r) ⇒ Object
Changes radius of vertices
24 25 26 |
# File 'lib/graph_visualizer.rb', line 24 def change_vertices_radius(r) @@vert_radius = r end |
#change_window_size(w, h) ⇒ Object
Changes window size
12 13 14 |
# File 'lib/graph_visualizer.rb', line 12 def change_window_size(w, h) (Window.get :window).set width: w, height: h end |
#clear_window ⇒ Object
clear screen
60 61 62 |
# File 'lib/graph_visualizer.rb', line 60 def clear_window Window.clear end |
#close_window ⇒ Object
close screen
66 67 68 |
# File 'lib/graph_visualizer.rb', line 66 def close_window Window.close end |
#set_graph(graph) ⇒ Object
Set the graph for visualization
48 49 50 51 52 53 54 55 56 |
# File 'lib/graph_visualizer.rb', line 48 def set_graph(graph) if graph.class != OrientedGraph and graph.class != UnorientedGraph raise ArgumentError, "Invalid graph type!" end clear_window set_vertices(graph) set_edges(graph) set_labels(graph) end |
#show_window ⇒ Object
show graph on the screen
72 73 74 |
# File 'lib/graph_visualizer.rb', line 72 def show_window Window.show end |