def CG8(): t1 = table.Table("data/posthistory.xml") t2 = group(t1,["UserId"],["PostId","CreationDate"],"list") t3 = order(t2,"PostId","CreationDate") # In each row, order postIds by date t4 = expand(t3) # Generate table with one row for each consecutive pair of postIds in each row of the original table g = graph.Graph("directed",False) g.addNodes(t1,"PostId") g.addEdges(t4,"PostId1","PostId2") return g
["UserId", "PostId1", "PostId2"]) t4 = group(t3, ["PostId1", "PostId2"]) g = makeGraph(t4, "PostId1", "PostId2", "undirected", False) #CG8 import table import graph import sql from condition import Condition t1 = table.Table("data/posthistory.xml") t2 = sql.group(t1, ["UserId"], ["PostId", "CreationDate"], "list") t3 = sql.order(t2, "PostId", "CreationDate") # In each row, order postIds by date t4 = sql.expand( t3 ) # Generate table with one row for each consecutive pair of postIds in each row of the original table g = graph.Graph("directed", False) g.addNodes(t1, "PostId") g.addEdges(t4, "PostId1", "PostId2") # CG9 import table import graph from gbuild import makeGraph from sql import select, project, rename, join, group from condition import Condition t1 = table.Table("data/badges.xml") #[UserId","Name"...] t2 = table.Table("data/posts.xml") #["Id","PostTypeId","OwnerUserId",...] t3 = join(t1, t2, ["UserId"], ["OwnerUserId"], ["Name"],
from condition import Condition t1 = table.Table("data/posthistory.xml") t2 = group(t1,["PostId","UserId"]) t3 = join(t2,t2,["UserId"],["UserId"],["PostId"],["PostId"],["UserId","PostId1","PostId2"]) t4 = group(t3,["PostId1","PostId2"]) g = makeGraph(t4,"PostId1","PostId2","undirected",False) #CG8 import table import graph import sql from condition import Condition t1 = table.Table("data/posthistory.xml") t2 = sql.group(t1,["UserId"],["PostId","CreationDate"],"list") t3 = sql.order(t2,"PostId","CreationDate") # In each row, order postIds by date t4 = sql.expand(t3) # Generate table with one row for each consecutive pair of postIds in each row of the original table g = graph.Graph("directed",False) g.addNodes(t1,"PostId") g.addEdges(t4,"PostId1","PostId2") # CG9 import table import graph from gbuild import makeGraph from sql import select, project, rename, join, group from condition import Condition t1 = table.Table("data/badges.xml") #[UserId","Name"...] t2 = table.Table("data/posts.xml") #["Id","PostTypeId","OwnerUserId",...] t3 = join(t1,t2,["UserId"],["OwnerUserId"],["Name"],["PostTypeId","ParentId","Id"]) t4 = select(t3, Condition("PostTypeId", "==", 1)) #Questions t5 = select(t3, Condition("PostTypeId", "==", 2)) #Answers