summaryrefslogtreecommitdiff
path: root/lib/git/async/graph.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-06-06 01:00:12 +0200
committerSebastian Thiel <byronimo@gmail.com>2010-06-06 01:00:12 +0200
commitb72e2704022d889f116e49abf3e1e5d3e3192d3b (patch)
tree65d2f5835a4853e72eb4b3cb5beb1b26aabcba36 /lib/git/async/graph.py
parentab59f78341f1dd188aaf4c30526f6295c63438b1 (diff)
downloadgitpython-b72e2704022d889f116e49abf3e1e5d3e3192d3b.tar.gz
Improved pool design and started rough implementation, top down to learn while going. Tests will be written soon for verification, its still quite theoretical
Diffstat (limited to 'lib/git/async/graph.py')
-rw-r--r--lib/git/async/graph.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/git/async/graph.py b/lib/git/async/graph.py
new file mode 100644
index 00000000..0c0a2137
--- /dev/null
+++ b/lib/git/async/graph.py
@@ -0,0 +1,36 @@
+"""Simplistic implementation of a graph"""
+
+class Node(object):
+ """A quick and dirty to the point implementation of a simple, and slow ascyclic graph.
+ Its not designed to support big graphs, and sports only the functionality
+ we need"""
+ __slots__ = ('in_nodes', 'out_nodes')
+
+
+class Graph(object):
+ """A simple graph implementation, keeping nodes and providing basic access and
+ editing functions"""
+ __slots__ = "nodes"
+
+ def __init__(self):
+ self.nodes = list()
+
+ def add_node(self, node):
+ """Add a new node to the graph"""
+ raise NotImplementedError()
+
+ def del_node(self, node):
+ """Delete a node from the graph"""
+ raise NotImplementedError()
+
+ def add_edge(self, u, v):
+ """Add an undirected edge between the given nodes u and v.
+ :raise ValueError: If the new edge would create a cycle"""
+ raise NotImplementedError()
+
+ def visit_input_depth_first(self, node, visitor=lambda n: True ):
+ """Visit all input nodes of the given node, depth first, calling visitor
+ for each node on our way. If the function returns False, the traversal
+ will not go any deeper, but continue at the next branch"""
+ raise NotImplementedError()
+