• 大小: 46.14MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-11-24
  • 语言: Python
  • 标签: 蓝噪声  离散数据  

资源简介

基于传统自适应蓝噪声采样(图形学中采样方法),实现离散数据的蓝噪声采样

资源截图

代码片段和文件信息

import networkx as nx
import matplotlib.pyplot as plt
import community
import datetime;
starttime = datetime.datetime.now()
G=nx.DiGraph();G1=nx.DiGraph();
fo = open(“Count_1.csv“‘r‘encoding=‘utf-8‘);
fw = open(“bc/bc.txt“‘w‘encoding=‘utf-8‘);
fw1 = open(“bc/bc1.txt“‘w‘encoding=‘utf-8‘);
fw2 = open(“bc/bc2.txt“‘w‘encoding=‘utf-8‘);
edges = [];
weighted_edges = [];
for line in fo.readlines():
    term = line.strip().split(‘‘);
    edges.append((int(term[0])int(term[1])));
    weighted_edges.append((int(term[0])int(term[1])int(term[2])));
G.add_edges_from(edges);
G1.add_weighted_edges_from(weighted_edges);

#algorithm from networkx 
#print(G.edges.data());print(G1.edges.data());
C  = nx.edge_betweenness_centrality(Gnormalized =False);
C1 = nx.edge_betweenness_centrality(G1normalized = False weight=‘weight‘);
C2 = nx.edge_betweenness_centrality(G1normalized =False);
nDG = G.to_undirected(False);
partials = community.best_partition(nDGweight=‘weight‘);
par_s = [];
for i in partials.values():
    par_s.append(i);
print(max(par_s));
print(len(partials));
print(partials);
#C = nx.communicability_betweenness_centrality(Gnormalized=False);
endtime = datetime.datetime.now()

print (endtime - starttime).seconds

for ij in zip(CC.values()):
    fw.write(str(i)+str(j)+‘\n‘);
fw1.write(str(len(C1))+‘\n‘);
for ij in zip(C1C1.values()):
    fw1.write(str(i)+str(j)+‘\n‘);
for ij in zip(C2C2.values()):
    fw2.write(str(i)+str(j)+‘\n‘);
fw.close();fw1.close();fw2.close();
print(‘end!‘);
# layout = nx.spring_layout(G)
# plt.figure(1)
# nx.draw(G pos=layout node_color=‘y‘)
# plt.figure(2)
# nx.draw(G pos=layout node_size=[(x+1) * 10 for x in C2.values()]node_color=‘r‘with_labels=True)
# plt.show()


# not use nx lib 
# valication of nx betweenness 


# CB = dict.fromkeys(G0.0)
# for s in G.nodes():
#     Pred = {w:[] for  w in G.nodes()}
#     dist = dict.fromkeys(GNone)
#     sigma = dict.fromkeys(G0.0)
#     dist[s] = 0
#     sigma[s] = 1
#     Q = Queue()
#     Q.put(s)
#     S = []
#     while not Q.empty():
#         v = Q.get()
#         S.append(v)
#         for w in G.neighbors(v):
#             if dist[w] == None:
#                 dist[w] = dist[v] + 1
#                 Q.put(w)
#             if dist[w] == dist[v] + 1:
#                 sigma[w] += sigma[v]
#                 Pred[w].append(v)
#     delta = dict.fromkeys(G0.0)
#     for w in S[::-1]:
#         for v in Pred[w]:
#             delta[v] += sigma[v]/sigma[w]*(1+delta[w])
#         if w != s:
#             CB[w] += delta[w]
# for v in CB:
#     CB[v] /= 2.0

# #compare with networkx‘s implements 
# print(sum(abs(CB[v]-C[v]) for v in G)) #1.59428026336e-13

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        391  2017-11-19 13:55  py_blueNoiseSampling\.project

     文件        499  2018-03-10 20:41  py_blueNoiseSampling\.pydevproject

     文件        125  2018-03-09 16:23  py_blueNoiseSampling\.settings\org.eclipse.core.resources.prefs

     文件        106  2018-03-09 16:32  py_blueNoiseSampling\.settings\org.eclipse.ltk.core.refactoring.prefs

     文件     260934  2018-03-05 21:58  py_blueNoiseSampling\allstation_w2v_name_sampling_2.txt

     文件      17534  2018-03-06 15:15  py_blueNoiseSampling\All_data_community.csv

     文件          0  2018-03-12 19:48  py_blueNoiseSampling\bc\bc.txt

     文件          0  2018-03-12 19:48  py_blueNoiseSampling\bc\bc1.txt

     文件          0  2018-03-12 19:48  py_blueNoiseSampling\bc\bc2.txt

     文件       2777  2018-03-12 19:48  py_blueNoiseSampling\betweenness-test.py

     文件       3247  2018-03-04 09:55  py_blueNoiseSampling\blue_noise_particles.py

     文件        771  2018-03-07 13:43  py_blueNoiseSampling\clique.py

     文件      84909  2018-03-12 19:51  py_blueNoiseSampling\Count_1.csv

     文件  109695994  2017-12-03 16:44  py_blueNoiseSampling\data\traincsv

     文件       1857  2017-12-03 16:44  py_blueNoiseSampling\data\train-0-5.pgm

     文件       1883  2017-12-03 16:44  py_blueNoiseSampling\data\train-1-0.pgm

     文件       1788  2017-12-03 16:44  py_blueNoiseSampling\data\train-2-4.pgm

     文件       1745  2017-12-03 16:44  py_blueNoiseSampling\data\train-3-1.pgm

     文件       1816  2017-12-03 16:44  py_blueNoiseSampling\data\train-4-9.pgm

     文件       1886  2017-12-03 16:44  py_blueNoiseSampling\data\train-5-2.pgm

     文件       1750  2017-12-03 16:44  py_blueNoiseSampling\data\train-6-1.pgm

     文件       1923  2017-12-03 16:44  py_blueNoiseSampling\data\train-7-3.pgm

     文件       1693  2017-12-03 16:44  py_blueNoiseSampling\data\train-8-1.pgm

     文件       1801  2017-12-03 16:44  py_blueNoiseSampling\data\train-9-4.pgm

     文件   47040016  1996-11-18 23:36  py_blueNoiseSampling\data\train-images.idx3-ubyte

     文件      60008  1996-11-18 23:36  py_blueNoiseSampling\data\train-labels.idx1-ubyte

     文件  109695994  2017-12-03 16:45  py_blueNoiseSampling\data\train.csv

     文件    1827377  2018-03-09 22:14  py_blueNoiseSampling\edge_bt_all.csv

     文件          0  2018-03-11 14:21  py_blueNoiseSampling\edge_bt_all_static.txt

     文件       2444  2018-03-10 11:45  py_blueNoiseSampling\edg_bar.py

............此处省略21个文件信息

评论

共有 条评论

相关资源