A New and More Efficient Implementation of an Undirected Graph Component Shawn Christopher Craft The...
-
Upload
kristopher-potter -
Category
Documents
-
view
213 -
download
0
Transcript of A New and More Efficient Implementation of an Undirected Graph Component Shawn Christopher Craft The...
A New and More Efficient Implementation of an
Undirected Graph Component
Shawn Christopher Craft
The Ohio State University Department of Computer and
Information Science
AbstractThis research project entails designing, specifying, coding, testing, debugging, and documenting different implementations of an undirected graph component for the RESOLVE/C++ Component Catalog. Each version uses the same abstract model to represent the state of an undirected graph and the same kernel operations to manipulate the state of that undirected graph. The implementation strategy changes for each version. The first five versions utilize the “classic” strategies (adjacency list, adjacency matrix, and edge list) in a variety of ways. The final version employs a novel data structure that allows each operation to execute in constant time, which dominates the other strategies.
Component Model
• Edge
math subtype EDGE is finite set of integer
exemplar e
constraint
|e| = 2
Component Model• Undirected Graph Model
math subtype UNDIRECTED_GRAPH_MODEL is (
nodes: finite set of integer
edges: finite set of EDGE
)
exemplar g
constraint
there exists nb: integer where (nb > 0)
(g.nodes = {n: integer where
(1 <= n <= nb) (n)}) and
for all e: EDGE where (e is in g.edges)
(for all n: integer where (n is in e)
(n is in g.nodes))
Component Operations• Set_Number_Of_Nodes
• Add_Edge
• Remove_Edge
• Remove_Any_Incident_Edge
• Remove_Any_Edge
• Is_Edge
• Number_Of_Nodes
• Number_Of_Incident_Edges
• Number_Of_Edges
Classic Implementations
• Adjacency List
• Adjacency Matrix
• Edge List
New Implementation
• The worst case time complexity of every operation is constant
• “New” Adjacency Matrix using Partitionable Array
Partitionable Array
• Specify what is “interesting”
• Find next “interesting” thing in constant time
• “Needle in a Haystack” analogy
• All operations now in constant time
Undirected Graph Component
• We want to represent an undirected graph as a C++ class.
• We want the representation to be very well-defined.
• We want the representation to be highly reusable.
• We want the representation to be easily extensible.
Component Advantages
• No need to “reinvent the wheel”
• Well-defined and well-understood behavior
• More efficient project development
RESOLVE Discipline
• Component-based software
• Language independent
• Mathematical modeling
• Well-defined specifications
• Objects and operations
• Swapping vs. copying
Picture of an Undirected Graph
1
2
3
4
5
6
Analysis of Time Complexity
Adjacency List Set_Number_Of_Nodes,
Remove_Edge,Remove_Any_Incident_Edge,Remove_Any_Edge, and Is_Edge arelinear in the number of nodes.
All other operations are constant.
Adjacency Matrix Set_Number_Of_Nodes is quadratic in
the number of nodes. Remove_Any_Incident_Edge and
Remove_Any_Edge are linear in thenumber of nodes.
All other operations are constant.
Edge List Set_Number_Of_Nodes is linear in the
number of nodes. Remove_Edge,
Remove_Any_Incident_Edge, andIs_Edge are linear in the number ofedges.
All other operations are constant.
“New” Adjacency Matrix All operations are constant.
Analysis of Space Complexity
Adjacency List Quadratic in the number of nodes
Adjacency Matrix Cubic in the number of nodes
Edge List Quadratic in the number of nodes and
the number of edges
“New” Adjacency Matrix Quartic in the number of nodes