0

I'm trying to load data from a text file. The .txt file contains 4 columns space separated. The structure of the .txt file is defined below

Id | Categogy | Related Id 1 | Related Id 2

The data looks like this

SQI9xPF9rdk Gadgets & Games SQI9xPF9rdk U0raaoN6I6M
4q5jSGOcZb8 Gadgets & Games SQI9xPF9rdk U0raaoN6I6M

The 1st, 3rd & 4th colums are related i.e the nodes will be 1st, 3rd, 4th coloumns respectively with edges being the links between them.

I'm trying to read the .txt file into igraph by first populating an adjacency matrix and then loading it in igraph but I'm getting the following errror.

Error:

Traceback (most recent call last):
 File "C:/Users/Lucy/PycharmProjects/Project/dataClean.py", line 9, in <module>
g=igraph.Graph.adj(m,mode="undirected")
AttributeError: type object 'Graph' has no attribute 'adj' 

Python Code..

 import igraph
 import numpy as np
 F = open('1.txt','r')
 m=np.matrix(F)
 g=igraph.Graph.adj(m,mode="undirected")

Can't Understand what I'm doing wrong..Please help

Lucy
  • 1,812
  • 15
  • 55
  • 93

1 Answers1

0

I think you are looking to use igraph.Graph.Adjacency, not igraph.Graph.adj. You are trying to call a method that does not exist.

http://igraph.org/python/doc/igraph.GraphBase-class.html#Adjacency

igraph Graph from numpy or pandas adjacency matrix

Matt
  • 973
  • 8
  • 10