diff --git a/UPGRADE.md b/UPGRADE.md
index b44985a699..e8d5802d1c 100644
--- a/UPGRADE.md
+++ b/UPGRADE.md
@@ -1,5 +1,15 @@
# Upgrade to 2.14
+## Deprecated constants of `Doctrine\ORM\Internal\CommitOrderCalculator`
+
+The following public constants have been deprecated:
+
+* `CommitOrderCalculator::NOT_VISITED`
+* `CommitOrderCalculator::IN_PROGRESS`
+* `CommitOrderCalculator::VISITED`
+
+These constants were used for internal purposes. Relying on them is discouraged.
+
## Deprecated `Doctrine\ORM\Query\AST\InExpression`
The AST parser will create a `InListExpression` or a `InSubselectExpression` when
diff --git a/lib/Doctrine/ORM/Internal/CommitOrder/Edge.php b/lib/Doctrine/ORM/Internal/CommitOrder/Edge.php
new file mode 100644
index 0000000000..f1457755ee
--- /dev/null
+++ b/lib/Doctrine/ORM/Internal/CommitOrder/Edge.php
@@ -0,0 +1,34 @@
+from = $from;
+ $this->to = $to;
+ $this->weight = $weight;
+ }
+}
diff --git a/lib/Doctrine/ORM/Internal/CommitOrder/Vertex.php b/lib/Doctrine/ORM/Internal/CommitOrder/Vertex.php
new file mode 100644
index 0000000000..c4747e032d
--- /dev/null
+++ b/lib/Doctrine/ORM/Internal/CommitOrder/Vertex.php
@@ -0,0 +1,38 @@
+ */
+ public $dependencyList = [];
+
+ public function __construct(string $hash, ClassMetadata $value)
+ {
+ $this->hash = $hash;
+ $this->value = $value;
+ }
+}
diff --git a/lib/Doctrine/ORM/Internal/CommitOrder/VertexState.php b/lib/Doctrine/ORM/Internal/CommitOrder/VertexState.php
new file mode 100644
index 0000000000..395db58d55
--- /dev/null
+++ b/lib/Doctrine/ORM/Internal/CommitOrder/VertexState.php
@@ -0,0 +1,17 @@
+state (integer)
- * Whether the node is NOT_VISITED or IN_PROGRESS
- *
- * - value (object)
- * Actual node value
*
- * - dependencyList (array)
- * Map of node dependencies defined as hashes.
+ * Keys are provided hashes and values are the node definition objects.
*
- * @var array
+ * @var array
*/
private $nodeList = [];
/**
* Volatile variable holding calculated nodes during sorting process.
*
- * @psalm-var list