 	}
 }
 
-private class DependencyNode: Comparable {
-	let identifier: DependencyIdentifier
-	let proposedVersion: SemanticVersion
-	var versionSpecifier: VersionSpecifier
-
-	var dependencyVersion: DependencyVersion<SemanticVersion> {
-		return DependencyVersion(identifier: identifier, version: proposedVersion)
-	}
-
-	init(identifier: DependencyIdentifier, proposedVersion: SemanticVersion, versionSpecifier: VersionSpecifier) {
-		precondition(versionSpecifier.satisfiedBy(proposedVersion))
-
-		self.identifier = identifier
-		self.proposedVersion = proposedVersion
-		self.versionSpecifier = versionSpecifier
-	}
-}
-
-private func <(lhs: DependencyNode, rhs: DependencyNode) -> Bool {
-	// Try higher versions first.
-	return lhs.proposedVersion > rhs.proposedVersion
-}
-
-private func ==(lhs: DependencyNode, rhs: DependencyNode) -> Bool {
-	return lhs.identifier == rhs.identifier
-}
-
-extension DependencyNode: Hashable {
-	private var hashValue: Int {
-		return identifier.hashValue
-	}
-}
-
-extension DependencyNode: Printable {
-	private var description: String {
-		return "\(identifier) @ \(proposedVersion) (restricted to \(versionSpecifier))"
-	}
-}
-
+/// A poor person's Set.
 private typealias DependencyNodeSet = [DependencyNode: ()]
 
+/// Represents an acyclic dependency graph in which each project appears at most
+/// once.
+///
+/// Dependency graphs can exist in an incomplete state, but will never be
+/// inconsistent (i.e., include versions that are known to be invalid given the
+/// current graph).
 private struct DependencyGraph: Equatable {
+	/// A full list of all nodes included in the graph.
 	var allNodes: DependencyNodeSet = [:]
+
+	/// All nodes that have dependencies, associated with those lists of
+	/// dependencies themselves.
 	var edges: [DependencyNode: DependencyNodeSet] = [:]
+
+	/// The root nodes of the graph (i.e., those dependencies that are listed
+	/// by the top-level project).
 	var roots: DependencyNodeSet = [:]
 
 	init() {}
 
+	/// Attempts to add the given node to the graph, optionally as a dependency
+	/// of another.
+	///
+	/// If the given node refers to a project which already exists in the graph,
+	/// this method will attempt to unify the version specifiers of both.
+	///
+	/// Returns the node as actually inserted into the graph (which may be
+	/// different from the node passed in), or an error if this addition would
+	/// make the graph inconsistent.
 	mutating func addNode(var node: DependencyNode, dependencyOf: DependencyNode?) -> Result<DependencyNode> {
 		if let index = allNodes.indexForKey(node) {
 			let existingNode = allNodes[index].0

			.merge(identity)
	}

	private func graphPermutationsForEachNode(nodes: [DependencyNode], dependencyOf: DependencyNode?, basedOnGraph inputGraph: DependencyGraph) -> ColdSignal<DependencyGraph> {
		return ColdSignal.lazy {
			var result = success(inputGraph)

	return result
}

/// A node in, or being considered for, an acyclic dependency graph.
private class DependencyNode: Comparable {
	/// The dependency that this node refers to.
	let identifier: DependencyIdentifier

	/// The version of the dependency that this node represents.
	///
	/// This version is merely "proposed" because it depends on the final
	/// resolution of the graph, as well as whether any "better" graphs exist.
	let proposedVersion: SemanticVersion

	/// The current requirements applied to this dependency.
	///
	/// This specifier may change as the graph is added to, and the requirements
	/// become more stringent.
	var versionSpecifier: VersionSpecifier

	/// A DependencyVersion equivalent to this node.
	var dependencyVersion: DependencyVersion<SemanticVersion> {
		return DependencyVersion(identifier: identifier, version: proposedVersion)
	}

	init(identifier: DependencyIdentifier, proposedVersion: SemanticVersion, versionSpecifier: VersionSpecifier) {
		precondition(versionSpecifier.satisfiedBy(proposedVersion))

		self.identifier = identifier
		self.proposedVersion = proposedVersion
		self.versionSpecifier = versionSpecifier
	}
}

private func <(lhs: DependencyNode, rhs: DependencyNode) -> Bool {
	// Try higher versions first.
	return lhs.proposedVersion > rhs.proposedVersion
}

private func ==(lhs: DependencyNode, rhs: DependencyNode) -> Bool {
	return lhs.identifier == rhs.identifier
}

extension DependencyNode: Hashable {
	private var hashValue: Int {
		return identifier.hashValue
	}
}

extension DependencyNode: Printable {
	private var description: String {
		return "\(identifier) @ \(proposedVersion) (restricted to \(versionSpecifier))"
	}
}
