zadt 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a5c19deae423e0c9c58bd1a0ca3426f9f5c35247
4
- data.tar.gz: 90eccd3bfea079e453115d2f37adc811050281f6
3
+ metadata.gz: 14d5d23662aa56e1c863e096a68657364b276574
4
+ data.tar.gz: 10f4b9da70a96defbe4c75c2c4920b09a3dab714
5
5
  SHA512:
6
- metadata.gz: 06af58c05476e6e9b876aa73db9d966ec36dd28a417aff76f5dede74648627eed9a28afae75de7f874aad8efa7ac592cf821959bf35e407dfeb6ba8e4af08160
7
- data.tar.gz: 3a3ec25e47c7c5c5c031ff03d5275b5959450fedee8176e6ea99be9b87fa2bcb91f9174078d3b0cd9401fd80ccbd55dd9fd8fdb610be4ad9110432d71e68d3e9
6
+ metadata.gz: 40eb3b8f4ab8ae3fa098838ba4416ef035c1f1bedd8bd5fa7aefb77f7fccc5dbe4d4853446c9f9a2569e8624cd361944f07f0b8c721dad03385d88d1646358f6
7
+ data.tar.gz: cf59f864501efdc60b3388e337afddfcf4cc0bb0abac48127871715785590cbd81591899cb807b80b8f0571da69ad9df4b6e06c5cab9366f3cdd14451d418788
data/README.md CHANGED
@@ -22,7 +22,7 @@ Or install it yourself as:
22
22
 
23
23
  Zadt::ADT::help will return a list of objects in the collection, as well as a brief description of each type.
24
24
 
25
- I also made a "help" function for each Data Type. Type Zadt::StackQueue.help get a list of functions for the StackQueue, and so on.
25
+ I also made a "help" function for each Data Type. Type Zadt::StackQueue.help get a list of methods for the StackQueue, and so on.
26
26
 
27
27
  And don't forget to require 'zadt' at the top!
28
28
 
@@ -32,11 +32,33 @@ A MinMaxStackQueue is an Queue object that allows the minimum and maximum values
32
32
 
33
33
  Since it is made out of Queues and Stacks, those data types are also available. I also provided StackQueue (functionally the same as a Queue), and a MinMaxStack, which is a Stack version of MinMaxStackQueue.
34
34
 
35
- ### Graph
35
+ ### Graphs
36
36
 
37
37
  A Graph is a data type that consists of Vertices, which are connected by Edges. In addition, a FaceGraph is a Graph which also consists of Faces: the space defined inside a set of cyclic edges.
38
38
 
39
- I'm still working on the exact functionality of FaceGraph, since I mainly built it to use for a different project, but it should still prove useful for certain situations. If you have any suggestions of useful bits to add, feel free to contact me below!
39
+ I'm still working on the exact functionality of FaceGraph, since I mainly built it to use for a different project, but it should still prove useful for certain situations. If you have any suggestions of useful bits to add, feel free to contact me!
40
+
41
+ Below are the specifics of such data types.
42
+
43
+ #### Graph
44
+
45
+ A Graph has the following methods
46
+ * add_vertex, adds a vertex to your graph
47
+ * remove_vertex(vertex), removes the given vertex from the graph (vertex must not be connected)
48
+ * make_connection(v1,v2), adds an edge between two vertices
49
+ * break_connection(v1,v2), removes an edge between two vertices
50
+ * find_connection(v1,v2), returns edge connecting two given vertices
51
+ * is_connected?(v1,v2), returns true if the two vertices are connected with an edge, false otherwise
52
+
53
+ #### FaceGraph
54
+
55
+ A FaceGraph has the following methods, in addition to its inheritance from Graph
56
+ * add_face(edges_array), makes a face with the given edges (must be cyclicly connected)
57
+ * make_original_face(num_edges), which makes a standard disconnected face
58
+ * add_attached_face(vertex_array, num_edges), which adds a face connected to the vertex_array
59
+ * find_neighbors(vertex_array), lists all faces containing the given vertices
60
+ * find_face_neighbors(face), which finds all neighbors of the given face. A neighbor of a face is defined as one that shares a vertex (not necessarily an edge)
61
+ * make_vertex_line(vertex_array), reorders a list of connected vertices by connection sequence
40
62
 
41
63
  ## Development
42
64
 
@@ -16,7 +16,7 @@ module Zadt
16
16
  puts "-FaceGraph, a sub-class of Graph which includes Faces"
17
17
  puts "--Face, a space surrounded by a cycle of Edges. Consists of Vertices and the Edges connecting them"
18
18
  puts ""
19
- puts "Each data type also has a help function. Type Zadt::Stack::help or Zadt::Stack::methods for a list of Stack methods, and so on for each data type."
19
+ puts "Each data type also has a help function. Type Zadt::Stack::help for a list of Stack methods, and so on for each data type."
20
20
  end
21
21
  end
22
22
  end
@@ -1,4 +1,3 @@
1
- module Zadt
2
1
  class Edge
3
2
  # Made up of a
4
3
  attr_reader :connection
@@ -9,29 +8,8 @@ module Zadt
9
8
  @value = value
10
9
  end
11
10
 
12
- def self.methods
13
- self.help
14
- end
15
-
16
-
17
11
  def inspect
18
12
  @connection.to_s
19
13
  end
20
14
 
21
- def help
22
- self.help
23
- end
24
-
25
- def methods
26
- help
27
- end
28
-
29
- def self.help
30
- puts "Edge has one method:"
31
- puts "#connection, which returns the vertices the edge connects"
32
- end
33
-
34
- private
35
-
36
15
  end
37
- end
@@ -1,6 +1,5 @@
1
1
  # require_relative 'vertex.rb'
2
2
  # require_relative 'edge.rb'
3
- module Zadt
4
3
  class Face
5
4
  attr_reader :edges, :vertices, :neighboring_faces
6
5
  # Contains
@@ -16,24 +15,6 @@ module Zadt
16
15
  end
17
16
 
18
17
  # TODO: Neighbors shouldn't be stored in Face, as FaceGraph takes care of this
19
- def self.help
20
- puts "Here are the functions for Face:"
21
-
22
- puts "#add_neighbor(face)"
23
- puts "#remove_neighbor(neighbor)"
24
- end
25
-
26
- def self.methods
27
- self.help
28
- end
29
-
30
- def help
31
- self.help
32
- end
33
-
34
- def methods
35
- help
36
- end
37
18
 
38
19
  def add_neighbor(face)
39
20
  # face_info is a catalog of information about the face's neighbor
@@ -86,4 +67,3 @@ module Zadt
86
67
  connected_vertices
87
68
  end
88
69
  end
89
- end
@@ -16,10 +16,15 @@ module Zadt
16
16
  super
17
17
  end
18
18
 
19
- def self.methods
20
- self.help
19
+ def self.help
20
+ FaceGraph.show_help_message
21
+ end
22
+
23
+ def help
24
+ FaceGraph.help
21
25
  end
22
26
 
27
+
23
28
  def add_face(edges_array)
24
29
  face = Face.new(edges_array)
25
30
  @faces << face
@@ -120,34 +125,6 @@ module Zadt
120
125
  neighbors - [face]
121
126
  end
122
127
 
123
- def help
124
- FaceGraph.help
125
- end
126
-
127
- def methods
128
- help
129
- end
130
-
131
-
132
-
133
- def self.help
134
- puts "Here are the functions for FaceGraph:"
135
- puts "#add_face(edges_array), makes a face with the given edges (must be cyclicly connected)"
136
- puts "#make_original_face(num_edges), which makes a standard disconnected face"
137
- puts "#add_attached_face(vertex_array, num_edges), which adds a face connected to the vertex_array"
138
- puts "#find_neighbors(vertex_array), lists all faces containing the given vertices"
139
- puts "#find_face_neighbors(vertex_array), which finds all neighbors of the given face"
140
- puts "--a neighbor of a face is defined as one that shares a vertex (not necessarily an edge)"
141
- puts "#make_vertex_line(vertex_array), reorders a list of connected vertices by connection sequence"
142
- puts ""
143
- puts "FaceGraph also inherits the following functions from Graph:"
144
- puts "#add_vertex"
145
- puts "#remove_vertex(vertex)"
146
- puts "#make_connection(v1,v2), adds an edge between two vertices"
147
- puts "#break_connection(v1,v2)"
148
- puts "#find_connection(v1,v2), returns edge connecting two given vertices"
149
- puts "#is_connected?(v1,v2)"
150
- end
151
128
 
152
129
  private
153
130
 
@@ -177,5 +154,24 @@ module Zadt
177
154
  face2.remove_neighbor(face1)
178
155
  face1.remove_neighbor(face2)
179
156
  end
157
+
158
+ def self.show_help_message
159
+ puts "Here are the methods for FaceGraph:"
160
+ puts "#add_face(edges_array), makes a face with the given edges (must be cyclicly connected)"
161
+ puts "#make_original_face(num_edges), which makes a standard disconnected face"
162
+ puts "#add_attached_face(vertex_array, num_edges), which adds a face connected to the vertex_array"
163
+ puts "#find_neighbors(vertex_array), lists all faces containing the given vertices"
164
+ puts "#find_face_neighbors(face), which finds all neighbors of the given face"
165
+ puts "--a neighbor of a face is defined as one that shares a vertex (not necessarily an edge)"
166
+ puts "#make_vertex_line(vertex_array), reorders a list of connected vertices by connection sequence"
167
+ puts ""
168
+ puts "FaceGraph also inherits the following functions from Graph:"
169
+ puts "#add_vertex"
170
+ puts "#remove_vertex(vertex)"
171
+ puts "#make_connection(v1,v2), adds an edge between two vertices"
172
+ puts "#break_connection(v1,v2)"
173
+ puts "#find_connection(v1,v2), returns edge connecting two given vertices"
174
+ puts "#is_connected?(v1,v2)"
175
+ end
180
176
  end
181
177
  end
@@ -20,8 +20,12 @@ module Zadt
20
20
  @value = Hash.new
21
21
  end
22
22
 
23
- def self.methods
24
- self.help
23
+ def help
24
+ Graph.help
25
+ end
26
+
27
+ def self.help
28
+ Graph.show_help_message
25
29
  end
26
30
 
27
31
  # Add a vertex
@@ -48,9 +52,12 @@ module Zadt
48
52
  # Make an edge between two vertices
49
53
  def make_connection(v1, v2)
50
54
  raise "already connected" if is_connected?(v1, v2)
55
+ # Make new edge
56
+ edge = Edge.new(v1, v2)
51
57
  # Connect the two using the vertex method "connect"
58
+ v1.connect(v2, edge)
59
+ v2.connect(v1, edge)
52
60
 
53
- edge = v1.connect(v2)
54
61
  # Add to edge catalog
55
62
  @edges << edge
56
63
  edge
@@ -86,16 +93,10 @@ module Zadt
86
93
  end
87
94
  end
88
95
 
89
- def help
90
- Graph.help
91
- end
96
+ private
92
97
 
93
- def methods
94
- help
95
- end
96
-
97
- def self.help
98
- puts "Here are the functions for Graph:"
98
+ def self.show_help_message
99
+ puts "Here are the methods for Graph:"
99
100
  puts "#add_vertex"
100
101
  puts "#remove_vertex(vertex)"
101
102
  puts "#make_connection(v1,v2), adds an edge between two vertices"
@@ -1,4 +1,4 @@
1
- module Zadt
1
+
2
2
  class Vertex
3
3
  # Connected by
4
4
  attr_accessor :edges
@@ -17,21 +17,13 @@ module Zadt
17
17
  @value = value
18
18
  end
19
19
 
20
- def self.methods
21
- self.help
22
- end
23
-
24
20
  # Make an edge between this vertex and another
25
- def connect(other_vertex)
21
+ def connect(other_vertex, edge)
26
22
  return nil if !other_vertex.is_a?(Vertex) || other_vertex == self
27
23
  raise "already connected" if is_connected?(other_vertex)
28
-
29
- edge = Edge.new(self, other_vertex)
30
24
  # Store connection info in this vertex
31
25
  @edges << edge
32
26
  @connections << other_vertex
33
- # Store connection info in other vertex
34
- other_vertex.store_connection_info(self, edge)
35
27
  edge
36
28
  end
37
29
 
@@ -45,31 +37,4 @@ module Zadt
45
37
  description += ": empty" if @value.empty?
46
38
  end
47
39
 
48
- # Used to store connection info in the second vertex
49
- # involved in a connection
50
- # Must needs be public, since it's called by a different vertex
51
- def store_connection_info(vertex, edge)
52
- @edges << edge
53
- @connections << vertex
54
- end
55
-
56
- def self.help
57
- puts "Here are the functions for Vertex:"
58
- puts "#connect(other_vertex)"
59
- puts "#is_connected?(other_vertex)"
60
- puts "#make_connection(v1,v2)"
61
- puts "#break_connection(v1,v2)"
62
- puts "#find_connection(v1,v2)"
63
- puts "#is_connected?(v1,v2)"
64
- end
65
-
66
- def help
67
- Vertex.methods
68
- end
69
-
70
- def methods
71
- help
72
- end
73
- private
74
40
  end
75
- end
@@ -1,3 +1,3 @@
1
1
  module Zadt
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.summary = %q{Zagorski ADT is a collection of advanced data types that are not included in the standard Ruby library.}
13
13
  spec.description = %q{Includes two different categories of Advanced Data Types: Array-Based, and Graphs.
14
14
  Array-Based Data Types include Stack, Queue, StackQueue, MinMaxStack, and MinMaxStackQueue.
15
- Graph Data Types include Graph, Vertex, Edge, FaceGraph, and Face.
15
+ Graph Data Types include Graph, which consists of Vertices and Edges, and FaceGraph, which includes Faces.
16
16
  Once installed, type "Zadt::ADT::help" for a list of datatypes
17
17
  and basic functionality.}
18
18
  spec.homepage = "https://github.com/MrMicrowaveOven/zadt.git"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zadt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Zagorski
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-21 00:00:00.000000000 Z
11
+ date: 2016-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -55,7 +55,7 @@ dependencies:
55
55
  description: |-
56
56
  Includes two different categories of Advanced Data Types: Array-Based, and Graphs.
57
57
  Array-Based Data Types include Stack, Queue, StackQueue, MinMaxStack, and MinMaxStackQueue.
58
- Graph Data Types include Graph, Vertex, Edge, FaceGraph, and Face.
58
+ Graph Data Types include Graph, which consists of Vertices and Edges, and FaceGraph, which includes Faces.
59
59
  Once installed, type "Zadt::ADT::help" for a list of datatypes
60
60
  and basic functionality.
61
61
  email: