1

More than 3 years have passed since last update.

組合せ最適化 - 典型問題 - 最大安定集合問題

Last updated at Posted at 2015-07-10

実行方法

usage
``````Signature: maximum_stable_set(g, weight='weight')
Docstring:

g: グラフ(node:weight)
weight: 重みの属性文字

最大安定集合の重みの合計と頂点番号リスト
``````
python
``````# CSVデータ
import pandas as pd, networkx as nx, matplotlib.pyplot as plt
from ortoolpy import graph_from_table, networkx_draw, maximum_stable_set
g = graph_from_table(tbn, tbe)[0]
t = maximum_stable_set(g)
pos = networkx_draw(g, node_color='white')
nx.draw_networkx_nodes(g, pos, nodelist=t[1])
plt.show()
print(t)
``````

``````(5.0, [1, 4])
``````

python
``````# pandas.DataFrame
from ortoolpy.optimization import MaximumStableSet
MaximumStableSet('data/node0.csv','data/edge0.csv')
``````
id x y demand weight
1 1 5 8 1 3
4 4 2 2 1 2
python
``````# 乱数データ
import networkx as nx, matplotlib.pyplot as plt
from ortoolpy import networkx_draw, maximum_stable_set
g = nx.random_graphs.fast_gnp_random_graph(10, 0.3, 1)
t = maximum_stable_set(g)
pos = networkx_draw(g, nx.spring_layout(g), node_color='white')
nx.draw_networkx_nodes(g, pos, nodelist=t[1])
plt.show()
``````

データ

Register as a new user and use Qiita more conveniently

1. You get articles that match your needs
2. You can efficiently read back useful information
3. You can use dark theme
What you can do with signing up
1