Example #1
0
def CG9():
	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
	t6 = join(t5,t4,["ParentId"],["Id"],["Name"],["Name"],["Id","Badge1","Badge2"])
	t7 = group(t6,["Badge1","Badge2"],"Count","cnt")
	g = graph.Graph("directed")
	g.addNodes(t1,"Name")
	g.addEdges(t7,"Badge1","Badge2",["Count"])
	return g
Example #2
0
def CG7():
	t1 = table.Table("data/posthistory.xml")
	t2 = group(t1,["PostId","UserId"])
	t3 = select(t1,attributes=["PostId","UserId"])
	t3 = join(t2,t2,[("UserId","UserId")])
	t4 = group(t3,["PostId1","PostId2"])
	g = graph.Graph("undirected",False)
	g.addNodes(t1,"PostId")
	g.addEdges(t4,"PostId1","PostId2")
	return g
Example #3
0
def CG1():
	t1 = table.Table("data/posts.xml")
	t2 = select(t1, Condition("PostTypeId","==", 1), ["Id","OwnerUserId"])
	t3 = select(t1, Condition("PostTypeId","==", 2), ["ParentId","OwnerUserId"])
	t4 = join(t2,t3,[("Id","ParentId")])
	t5 = group(t4, ["OwnerUserId1", "OwnerUserId2"], "Count", "cnt")
	g = graph.Graph("directed")
	g.addNodes(t1,"OwnerUserId")
	g.addEdges(t5,"OwnerUserId1","OwnerUserId2",["Count"])
	return g
Example #4
0
def CG3():
	t1 = table.Table("data/posts.xml") #["Id","PostTypeId","OwnerUserId",...]   
	t2 = table.Table("data/comments.xml") #["PostId","UserId","Text",...]
	t3 = select(t1, attributes=["Id","OwnerUserId"])
	t4 = select(t2, attributes=["PostId","UserId"])
	t5 = join(t4,t3,[("PostId","Id")])
	g = graph.Graph("multiedge")
	g.addNodes(t1,"OwnerUserId")
	g.addNodes(t2,"UserId")
	g.addEdges(t5,"UserId","OwnerUserId")
	return g
Example #5
0
def CG2():
	t1 = table.Table("data/posts.xml") #["Id","PostTypeId","OwnerUserId",...] 
	t2 = table.Table("data/votes.xml") #["PostId","VoteTypeId","UserId",...]
	t3 = select(t1, attributes=["Id","OwnerUserId"])
	t4 = select(t2, Condition("VoteTypeId", "==", 2),["PostId","UserId"])
	t5 = join(t4,t3,[("PostId","Id")])
	t6 = group(t5,["UserId","OwnerUserId"], "Count","cnt")
	g = graph.Graph("directed")
	g.addNodes(t1,"OwnerUserId")
	g.addNodes(t2,"UserId")
	g.addEdges(t6,"UserId","OwnerUserId",["Count"])
	return g
Example #6
0
# CG1
import table
import graph
from gbuild import makeGraph
from sql import select, project, rename, join, group
from condition import Condition

t1 = table.Table("data/posts.xml")
t2 = select(t1, Condition("PostTypeId", "==", 1), ["Id", "OwnerUserId"])
t3 = select(t1, Condition("PostTypeId", "==", 2), ["ParentId", "OwnerUserId"])
t4 = join(t2, t3, [("Id", "ParentId")])
t5 = group(t4, ["OwnerUserId1", "OwnerUserId2"], "Count", "cnt")
g = graph.Graph("directed")
g.addNodes(t1, "OwnerUserId", [])
g.addEdges(t5, "UserId1", "UserId2", ["Count"])

# CG2
import table
import graph
from gbuild import makeGraph
from sql import select, project, rename, join, group
from condition import Condition

t1 = table.Table("data/posts.xml")  #["Id","PostTypeId","OwnerUserId",...]
t2 = table.Table("data/votes.xml")  #["PostId","VoteTypeId","UserId",...]
t3 = select(t2, Condition("VoteTypeId", "==", 2))
t4 = join(t3, t1, ["PostId"], ["Id"], ["UserId"], ["OwnerUserId"],
          ["Id", "UserId1", "UserId2"])
t5 = group(t4, ["UserId1", "UserId2"], "Count", "cnt")
g = graph.Graph("directed")
g.addNodes(t1, "OwnerUserId", [])
Example #7
0
# CG1
import table
import graph
from gbuild import makeGraph
from sql import select, project, rename, join, group
from condition import Condition
t1 = table.Table("data/posts.xml")
t2 = select(t1, Condition("PostTypeId","==", 1), ["Id","OwnerUserId"])
t3 = select(t1, Condition("PostTypeId","==", 2), ["ParentId","OwnerUserId"])
t4 = join(t2,t3,[("Id","ParentId")])
t5 = group(t4, ["OwnerUserId1", "OwnerUserId2"], "Count", "cnt")
g = graph.Graph("directed")
g.addNodes(t1,"OwnerUserId",[])
g.addEdges(t5,"UserId1","UserId2",["Count"])

# CG2
import table
import graph
from gbuild import makeGraph
from sql import select, project, rename, join, group
from condition import Condition
t1 = table.Table("data/posts.xml") #["Id","PostTypeId","OwnerUserId",...] 
t2 = table.Table("data/votes.xml") #["PostId","VoteTypeId","UserId",...]  
t3 = select(t2, Condition("VoteTypeId", "==", 2))
t4 = join(t3,t1,["PostId"],["Id"],["UserId"],["OwnerUserId"],["Id","UserId1","UserId2"])
t5 = group(t4,["UserId1","UserId2"], "Count","cnt")
g = graph.Graph("directed")
g.addNodes(t1,"OwnerUserId",[])
g.addNodes(t2,"UserId",[])
g.addEdges(t5,"UserId1","UserId2",["Count"])