当前位置:网站首页>从sparse.csc.csr_matrix生成邻接矩阵
从sparse.csc.csr_matrix生成邻接矩阵
2022-07-06 11:36:00 【NorburyL】
需要photo.edglist和cs.edglist
solution1
通过输出str,和str的操作过滤。
result
fail,不能完全获取到数据,部分结点的链接结点太多了,表示不出来。
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)) # 将字符串转换为列表
# # 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
将ndarray 与 scipy.sparse.csc.csr_matrix 的互转
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
成功
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")
边栏推荐
- 受益匪浅,安卓面试问题
- Take a look at how cabloyjs workflow engine implements activiti boundary events
- 如何自定义动漫头像?这6个免费精品在线卡通头像生成器,看一眼就怦然心动!
- 中缀表达式转后缀表达式详细思路及代码实现
- 打家劫舍III[后序遍历与回溯+动态规划]
- 潇洒郎: AttributeError: partially initialized module ‘cv2‘ has no attribute ‘gapi_wip_gst_GStreamerPipe
- 系统性详解Redis操作Hash类型数据(带源码分析及测试结果)
- Interview assault 63: how to remove duplication in MySQL?
- 主从搭建报错:The slave I/O thread stops because master and slave have equal MySQL serv
- MATLAB中deg2rad和rad2deg函数的使用
猜你喜欢

An error occurs when installing MySQL: could not create or access the registry key needed for the

思维导图+源代码+笔记+项目,字节跳动+京东+360+网易面试题整理

黑马--Redis篇

The list of people who passed the fifth phase of personal ability certification assessment was published

Interface test tool - postman

Problems encountered in using RT thread component fish

Meilu biological IPO was terminated: the annual revenue was 385million, and Chen Lin was the actual controller

LeetCode-1279. 红绿灯路口

保证接口数据安全的10种方案

Solution of intelligent management platform for suppliers in hardware and electromechanical industry: optimize supply chain management and drive enterprise performance growth
随机推荐
谷粒商城--分布式高级篇P129~P339(完结)
今日直播 | “人玑协同 未来已来”2022弘玑生态伙伴大会蓄势待发
[translation] micro survey of cloud native observation ability. Prometheus leads the trend, but there are still obstacles to understanding the health of the system
安装Mysql报错:Could not create or access the registry key needed for the...
【计算情与思】扫地僧、打字员、信息恐慌与奥本海默
The second day of rhcsa study
Help improve the professional quality of safety talents | the first stage of personal ability certification and assessment has been successfully completed!
R language uses rchisq function to generate random numbers that conform to Chi square distribution, and uses plot function to visualize random numbers that conform to Chi square distribution
Unbalance balance (dynamic programming, DP)
学习探索-使用伪元素清除浮动元素造成的高度坍塌
Xingnuochi technology's IPO was terminated: it was planned to raise 350million yuan, with an annual revenue of 367million yuan
Zero foundation entry polardb-x: build a highly available system and link the big data screen
Don't miss this underestimated movie because of controversy!
Actf 2022 came to a successful conclusion, and 0ops team won the second consecutive championship!!
Meilu biological IPO was terminated: the annual revenue was 385million, and Chen Lin was the actual controller
Using clip path to draw irregular graphics
C # use Marshall to manually create unmanaged memory in the heap and use
Graffiti intelligence is listed on the dual main board in Hong Kong: market value of 11.2 billion Hong Kong, with an annual revenue of 300 million US dollars
Lick the dog until the last one has nothing (simple DP)
包装行业商业供应链管理平台解决方案:布局智慧供应体系,数字化整合包装行业供应链