Exemplo n.º 1
0
def load_crossnet_to_graph(context,
                           edgeId,
                           srcName,
                           dstName,
                           filepath,
                           Graph,
                           prefix="miner"):
    srcId = srcName + "SrcId"
    dstId = dstName + "DstId"
    schema = snap.Schema()
    schema.Add(snap.TStrTAttrPr(edgeId, snap.atStr))
    schema.Add(snap.TStrTAttrPr("datasetId", snap.atStr))
    schema.Add(snap.TStrTAttrPr(srcId, snap.atStr))
    schema.Add(snap.TStrTAttrPr(dstId, snap.atStr))
    crossnet = snap.TTable.LoadSS(schema, filepath, context, DELIMITER,
                                  snap.TBool(False))
    crossName = prefix + "-" + dstName + "-" + srcName
    Graph.AddCrossNet(srcName, dstName, crossName, False)
    snap.LoadCrossNetToNet(Graph, srcName, dstName, crossName, crossnet, srcId,
                           dstId, snap.TStrV())
Exemplo n.º 2
0
def ttableToTmmnet():

    # load table
    t0 = t()
    context = snap.TTableContext()

    schema = snap.Schema()
    schema.Add(snap.TStrTAttrPr("srcID", snap.atInt))
    schema.Add(snap.TStrTAttrPr("dstID", snap.atInt))

    edge_table = snap.TTable.LoadSS(schema, NW.small, context, "\t",
                                    snap.TBool(False))
    t1 = reportTime(t0, "TTABLE")

    # convert table to TMMNet
    mmnet = snap.TMMNet.New()
    edgeattrv = snap.TStrV()
    edgeattrv.Add("edgeattr1")

    CrossG = snap.LoadCrossNetToNet(mmnet, "Mode1", "Mode2", "Cross1",
                                    edge_table, "srcID", "dstID", edgeattrv)

    reportTime(t1, "convert TTABLE to CrossNet")
prereqs_table.Save(FOut)
FOut.Flush()
instructors_table.Save(FOut)
FOut.Flush()
context.Save(FOut)
FOut.Flush()

#Create TMMNet
mmnet = snap.TMMNet.New()
nodeattrv = snap.TStrV()
snap.LoadModeNetToNet(mmnet, "students", advisors_table, "StudentID", nodeattrv)
snap.LoadModeNetToNet(mmnet, "courses", instructors_table, "CourseID", nodeattrv)
snap.LoadModeNetToNet(mmnet, "profs", advisors_table, "ProfID", nodeattrv)

edgeattrv = snap.TStrV()
snap.LoadCrossNetToNet(mmnet, "students", "students", "friends", friends_table, "Student1ID", "Student2ID", edgeattrv)
snap.LoadCrossNetToNet(mmnet, "students", "profs", "advisors", advisors_table, "StudentID", "ProfID", edgeattrv)
snap.LoadCrossNetToNet(mmnet, "students", "courses", "enrollments", enrollments_table, "StudentID", "CourseID", edgeattrv)
snap.LoadCrossNetToNet(mmnet, "courses", "courses", "prereqs", prereqs_table, "CourseID", "PrereqCourseID", edgeattrv)
snap.LoadCrossNetToNet(mmnet, "courses", "profs", "instructors", instructors_table, "CourseID", "ProfID", edgeattrv)

# Convert to TNEANet

crossnetids = snap.TIntV()
crossnetids.Add(mmnet.GetCrossId("friends"))
crossnetids.Add(mmnet.GetCrossId("advisors"))
crossnetids.Add(mmnet.GetCrossId("enrollments"))
crossnetids.Add(mmnet.GetCrossId("prereqs"))
crossnetids.Add(mmnet.GetCrossId("instructors"))

crossnetnames = snap.TStrV()
Exemplo n.º 4
0
    logging.info('Done loading Disease Mode')
    snap.LoadModeNetToNet(Graph, "Disease", disease_mode, "DiseaseId", snap.TStr64V())
except ConfigParser.NoOptionError:
    logging.info('Skipping Disease Mode')

# Loading Cross-Nets
try:
    chemical_chemical_crossnet_file = config.get('Cross-Net', 'Chemical-Chemical')
    cccschema = snap.Schema()
    cccschema.Add(snap.TStrTAttrPr("CCEdgeId", snap.atStr))
    cccschema.Add(snap.TStrTAttrPr("datasetId", snap.atStr))
    cccschema.Add(snap.TStrTAttrPr("CSrcId", snap.atStr))
    cccschema.Add(snap.TStrTAttrPr("CDstId", snap.atStr))
    chemical_chemical_crossnet = snap.TTable.LoadSS(cccschema, chemical_chemical_crossnet_file, context, "\t", snap.TBool(False))
    logging.info('Done loading Chemical-Chemical Cross-Net')
    snap.LoadCrossNetToNet(Graph, "Chemical", "Chemical", "Chemical-Chemical", chemical_chemical_crossnet, "CSrcId", "CDstId", snap.TStr64V())
except ConfigParser.NoOptionError:
    logging.info('Skipping Chemical-Chemical Cross-Net')

try:
    chemical_gene_crossnet_file = config.get('Cross-Net', 'Chemical-Gene')
    cgcschema = snap.Schema()
    cgcschema.Add(snap.TStrTAttrPr("CGEdgeId", snap.atStr))
    cgcschema.Add(snap.TStrTAttrPr("datasetId", snap.atStr))
    cgcschema.Add(snap.TStrTAttrPr("CSrcId", snap.atStr))
    cgcschema.Add(snap.TStrTAttrPr("GDstId", snap.atStr))
    chemical_gene_crossnet = snap.TTable.LoadSS(cgcschema, chemical_gene_crossnet_file, context, "\t", snap.TBool(False))
    logging.info('Done loading Chemical-Gene Cross-Net')
    snap.LoadCrossNetToNet(Graph, "Chemical", "Gene", "Chemical-Gene", chemical_gene_crossnet, "CSrcId", "GDstId", snap.TStr64V())
except ConfigParser.NoOptionError:
    logging.info('Skipping Chemical-Gene Cross-Net')
Exemplo n.º 5
0
snap.LoadModeNetToNet(mmnet, "authors", AuthT, "AuthorID", nodeattrv)
print time.ctime()


# In[4]:

print time.ctime()
snap.LoadModeNetToNet(mmnet, "affls", AfflT, "AfflID", nodeattrv)
print time.ctime()


# In[ ]:

edgeattrv = snap.TStrV()
print time.ctime()
snap.LoadCrossNetToNet(mmnet, "papers", "authors", "papauth", PapAuthAfflT, "PaperID", "AuthorID", edgeattrv)
print time.ctime()


# In[5]:

edgeattrv = snap.TStrV()
print time.ctime()
snap.LoadCrossNetToNet(mmnet, "papers", "affls", "papaffl", PapAuthAfflT, "PaperID", "AfflID", edgeattrv)
print time.ctime()


# In[ ]:

print time.ctime()
snap.LoadCrossNetToNet(mmnet, "authors", "affls", "authaffl", PapAuthAfflT, "AuthorID", "AfflID", edgeattrv)