         }
     }
 }
+
+/**
+ A weighted directed Adjacency List implementation of weighted, directed
+ graphs. Similar to the WeightedUndirected adjacency list, but with asymmetric
+ edges.
+
+ Weights are stored separately from edges, in a nested dictionary of type
+ [Vertex: [Vertex: Double]].
+ */
+final public class WeightedDirectedAList<Vertex: Hashable> :
+                AdjacencyList<Vertex>, WeightedDirectedGraph {
+    
+    /**
+     A nested dictionary stores the weight of each edge, and is accessed like
+     weightTable[from][to]. Direction matters in this class, so that is the
+     weight of the edge from -> to.
+     */
+    private var weightTable = [Vertex: [Vertex: Double]]()
+
+    required public override init() {
+        super.init()
+    }
+
+    /**
+     A computed property which is an array of edges in the graph, represented
+     as (Vertex, Vertex) tuples. Read-only.
+     */
+    public var edges: [(Vertex, Vertex)] {
+        var result = [(Vertex, Vertex)]()
+        for (vertex, neighbors) in adjacencyList {
+            for neighbor in neighbors {
+                result.append((vertex, neighbor))
+            }
+        }
+        return result
+    }
+
+    /**
+     Computes the weight associated with the given edge, by looking it up
+     in the weight table.
+
+     Like other methods on directed graphs, the order of the parameters is
+     important. weight(from, to) may exist while weight(to, from) is nil.
+
+     - parameter from: the source vertex of the desired edge.
+     - parameter to: the destination vertex of the desired edge.
+
+     - returns: The weight of the edge (from -> to), a Double, or nil if the
+       edge does not exist in the graph.
+
+     - throws: `GraphError.VertexNotPresent` if either vertex doesn't exist.
+     */
+    public func weight(from: Vertex, to: Vertex) throws -> Double? {
+        guard adjacencyList[from] != nil else {
+            throw GraphError.VertexNotPresent
+        }
+        guard adjacencyList[to] != nil else {
+            throw GraphError.VertexNotPresent
+        }
+
+        return weightTable[from]?[to]
+    }
+
+    /**
+     Adds a new edge of unspecified weight to the graph.
+
+     Required to satisfy graph protocol - this is bad.
+     Currently, this adds a zero-weight edge.
+    
+     Probably don't use it with weighted adjacency lists.
+     */
+    public func addEdge(from: Vertex, to: Vertex) throws {
+        try addEdge(from, to: to, weight: 0.0)
+    }
+
+    /**
+     Adds a new weighted edge to the graph from one vertex to another.
+
+     Changes the graph in-place to add the weighted edge.
+
+     - parameter from: The source of the edge to add.
+     - parameter to: The source of the edge to add.
+     - parameter weight: The weight of the egde to add, a double.
+
+     - throws: `GraphError.VertexNotPresent` if either vertex doesn't exist.
+     */
+    public func addEdge(from: Vertex, to: Vertex, weight: Double) throws {
+        guard adjacencyList[from] != nil else {
+            throw GraphError.VertexNotPresent
+        }
+        guard adjacencyList[to] != nil else {
+            throw GraphError.VertexNotPresent
+        }
+        adjacencyList[from]!.append(to)
+
+        if weightTable[from] == nil {
+            weightTable[from] = [to: weight]
+        } else {
+            weightTable[from]![to] = weight
+        }
+    }
+
+    /**
+     Remove an edge between two given vertices in the graph.
+
+     - parameter from: The source of the edge to remove.
+     - parameter to: The destination of the edge to remove.
+     Not interchangable. This removes (from -> to) but doesn't touch the edge
+     (to -> from).
+
+     - throws: `GraphError.VertexNotPresent if those vertices don't exist,
+       and `GraphError.EdgeNotPresent` if the edge doesn't exist.
+     */
+    public func removeEdge(from: Vertex, to: Vertex) throws {
+        guard adjacencyList[from] != nil else {
+            throw GraphError.VertexNotPresent
+        }
+        guard let neighborsTo = adjacencyList[to] else {
+            throw GraphError.VertexNotPresent
+        }
+        guard neighborsTo.contains(from) else {
+            throw GraphError.EdgeNotPresent
+        }
+        guard weightTable[from]?[to] != nil else {
+            throw GraphError.EdgeNotPresent
+            // This is even worse than just edge not present, because it means
+            // the edge exists in the adjacencyList but not the weight table.
+        }
+
+        removeFromArray(to, fromArr: &adjacencyList[from]!)
+
+        weightTable[from]!.removeValueForKey(to)
+    }
+}

    }

    /**
     Adds a new disconnected vertex to the graph.

     - parameter vertex: The vertex to add.
    

    /**
     A computed array of all the edges in the graph, as tuples of vertices.

     since these graphs are undirected, it would be possible to duplicate every
     edge in this array, since an undirected graph is technically a directed
     graph with 2E edges, one in each direction. We chose the other behavior,
     so if (u, v) is an edge in the graph it appears in this array as exactly
     one of (u, v) and (v, u), arbitrarily.

     - Complexity: O(E)
     */
    public var edges: [(Vertex, Vertex)] {
        var result = [(Vertex, Vertex)]()
