最近 ipython 开始表现得很奇怪。我现在用的是8.20版本。如果我按向上箭头,它不会给我最新的一行,而是给我很久以前的东西。
我怎样才能解决这个问题?
我在 ubuntu 20.04 上。
这是一个文字记录:
Python 3.8.10 (default, Mar 15 2022, 12:22:08)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.2.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: x=2
In [2]: %history
x=2
%history
In [3]: random.choices(range(2), weights=probs)
Run Code Online (Sandbox Code Playgroud)
[3] 行来自按向上箭头。
我有一个大的二分图,我可以使用Hopcroft-Karp快速找到最大匹配。但我真正想要的是同一个图的数百个不同的最大匹配。我怎样才能得到那些?
这是一个显示最大匹配的小型二分图示例。
类似的图表可以用以下方法制作:
import igraph as ig
from scipy.sparse import random, find
from scipy import stats
from numpy.random import default_rng
import numpy as np
from igraph import Graph, plot
np.random.seed(7)
rng = default_rng()
rvs = stats.poisson(2).rvs
S = random(20, 20, density=0.35, random_state=rng, data_rvs=rvs)
triples = [*zip(*find(S))]
edges = [(triple[0], triple[1]+20) for triple in triples]
print(edges)
types = [0]*20+[1]*20
g = Graph.Bipartite(types, edges)
matching = g.maximum_bipartite_matching()
layout = g.layout_bipartite()
visual_style={}
visual_style["vertex_size"] = 10
visual_style["bbox"] = (600,300)
plot(g, bbox=(600, 200), layout=g.layout_bipartite(), …Run Code Online (Sandbox Code Playgroud)