Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 01af34c

Browse files
Illustration complete bipartite graph
1 parent be882e8 commit 01af34c

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

‎OptimalTransportWasserteinDistance.ipynb

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,38 @@
288288
"\n",
289289
"#### Complete bipartite graph\n",
290290
"The algorithm can equivalently be described by formulating the problem using a complete bipartite graph. We recall that a bipartite graph, or a biclique is a special kind of bipartite graph where every vertex of the first set is connected to every vertex of the second set. More formally, a complete bipartite graph is a graph whose vertices can be partitioned into two subsets $V_1$ and $V_2$ such that no edge has both endpoints in the same subset, and every possible edge that could connect vertices in different subsets is part of the graph. That is, it is a bipartite graph $(V_1, V_2, E)$ such that for every pair of vertices $v_1 \\in V_1$ and $v_2 \\in V_2,ドル $v_1 v_2$ is an edge in $E$. A complete bipartite graph with partitions of size $\\|V1\\| = m$ and $\\|V2\\| = n,ドル is denoted $K_{m,n}$ every two graphs with the same notation are isomorphic.\n",
291+
"##### Illustration\n",
292+
"Here is an illustration of a complete bipartite graph with m = 5 and n = 3\n",
293+
"![Illustration of a complete bipartite graph with m = 5 and n = 3](data/complete_bipartite.png)\n",
291294
"\n",
292295
"#### Perfect matching\n",
293296
"In graph theory, a perfect matching in a graph is a matching that covers every vertex of the graph. More formally, given a graph $G = (V, E),ドル a perfect matching in $G$ is a subset $M$ of edge set $E,ドル such that every vertex in the vertex set $V$ is adjacent to exactly one edge in $M$.\n",
294297
"\n",
295-
"### Example\n",
296-
"https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.linear_sum_assignment.html"
298+
"### Numerical example\n",
299+
"The next example comes from [scipy documentation](https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.linear_sum_assignment.html)"
300+
]
301+
},
302+
{
303+
"cell_type": "code",
304+
"execution_count": 10,
305+
"metadata": {},
306+
"outputs": [
307+
{
308+
"name": "stdout",
309+
"output_type": "stream",
310+
"text": [
311+
"[1 0 2]\n",
312+
"5\n"
313+
]
314+
}
315+
],
316+
"source": [
317+
"import numpy as np\n",
318+
"cost = np.array([[4, 1, 3], [2, 0, 5], [3, 2, 2]])\n",
319+
"from scipy.optimize import linear_sum_assignment\n",
320+
"row_ind, col_ind = linear_sum_assignment(cost)\n",
321+
"print(col_ind)\n",
322+
"print(cost[row_ind, col_ind].sum())"
297323
]
298324
},
299325
{

‎data/complete_bipartite.png

116 KB
Loading[フレーム]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /