当前位置:网站首页>From spark csc. csr_ Matrix generate adjacency matrix
From spark csc. csr_ Matrix generate adjacency matrix
2022-07-06 19:36:00 【NorburyL】
need photo.edglist and cs.edglist
solution1
By output str, and str Operation filtering of .
result
fail, Unable to obtain data completely , There are too many link nodes in some nodes , I can't show it .
code
import scipy
from edglist_utils import load_network_data
from scipy import sparse
network_file = 'photo'
adj, features, Y = load_network_data('graphsage/input/' + network_file + '.mat')
f2 = open("graphsage/cora_adj_list.txt", 'w')
f1 = open("graphsage/cora_create_list.txt", 'w')
# for i in range(2708):
# f2.write(str(i) + "\n" + str(adj[i]) + "\n\n")
# for part in adj[i]:
#
#
# part = str(part).replace(' (0, ', '')
# part = str(part).replace(') 1', '')
# part = str(part).replace(' : :\n', '')
# # list_str = list(str(part)) # Convert string to list
# # print(str(i)+","+part)
# quote_list = part.split('\n')
# for quote in quote_list:
# if (i < int(quote)) :
# f1.write(str(i) + "," + str(quote)+"\n")
# print(str(i) + "," + str(quote))
solution2
take ndarray And scipy.sparse.csc.csr_matrix Of each other
url
https://huwang.blog.csdn.net/article/details/84623786?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1-84623786-blog-83036442.pc_relevant_default&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1-84623786-blog-83036442.pc_relevant_default&utm_relevant_index=2
result
success
code
import scipy
from edglist_utils import load_network_data
from scipy import sparse
network_file = 'cs'
adj, features, Y = load_network_data('graphsage/input/' + network_file + '.mat')
f1 = open("graphsage/cs_create_list.txt", 'w')
my_matrix = scipy.sparse.csc_matrix(adj)
my_array = my_matrix.A
print(type(my_array))
print(len(my_array))
print(int(my_array[2][1]))
for i in range(len(my_array)):
for j in range(len(my_array)):
if int(my_array[i][j]) == 1 and i < j:
f1.write(str(i) + "," + str(j) + "\n")
边栏推荐
- JDBC details
- 数学知识——高斯消元(初等行变换解方程组)代码实现
- Characteristic colleges and universities, jointly build Netease Industrial College
- Simple understanding of MySQL database
- 打家劫舍III[后序遍历与回溯+动态规划]
- Translation D28 (with AC code POJ 26:the nearest number)
- Learning and Exploration - function anti shake
- MATLAB中deg2rad和rad2deg函数的使用
- 思維導圖+源代碼+筆記+項目,字節跳動+京東+360+網易面試題整理
- About image reading and processing, etc
猜你喜欢

今日直播 | “人玑协同 未来已来”2022弘玑生态伙伴大会蓄势待发

Don't miss this underestimated movie because of controversy!

C language daily practice - day 22: Zero foundation learning dynamic planning

PMP practice once a day | don't get lost in the exam -7.6

LeetCode-1279. Traffic light intersection

冒烟测试怎么做
![[translation] micro survey of cloud native observation ability. Prometheus leads the trend, but there are still obstacles to understanding the health of the system](/img/63/3addcecb69dcb769c4736653952f66.png)
[translation] micro survey of cloud native observation ability. Prometheus leads the trend, but there are still obstacles to understanding the health of the system
In depth analysis, Android interview real problem analysis is popular all over the network

Mind map + source code + Notes + project, ByteDance + JD +360+ Netease interview question sorting
![打家劫舍III[后序遍历与回溯+动态规划]](/img/9b/e9eeed138e46afdeed340bf2629ee1.png)
打家劫舍III[后序遍历与回溯+动态规划]
随机推荐
【pytorch】yolov5 训练自己的数据集
[translation] supply chain security project in toto moved to CNCF incubator
Interview assault 63: how to remove duplication in MySQL?
谷粒商城--分布式高级篇P129~P339(完结)
Interview assault 63: how to remove duplication in MySQL?
Detailed idea and code implementation of infix expression to suffix expression
Reflection and illegalaccessexception exception during application
Yyds dry goods inventory leetcode question set 751 - 760
Characteristic colleges and universities, jointly build Netease Industrial College
Fast power template for inverse element, the role of inverse element and example [the 20th summer competition of Shanghai University Programming League] permutation counting
力扣101题:对称二叉树
USB host driver - UVC swap
Problems encountered in using RT thread component fish
How to type multiple spaces when editing CSDN articles
Spark foundation -scala
short i =1; I=i+1 and short i=1; Difference of i+=1
反射及在运用过程中出现的IllegalAccessException异常
黑马--Redis篇
Using clip path to draw irregular graphics
受益匪浅,安卓面试问题