func TestGetNeighbors(t *testing.T) {
	gm = new(spiderDB.GraphManager)

	gm.Initialize()
	defer gm.ClearAll()

	hgw := socialGraph.NewSocialNode("http://upload.wikimedia.org/wikipedia/commons/thumb/7/7f/H_G_Wells_pre_1922.jpg/220px-H_G_Wells_pre_1922.jpg",
		"Herbert Wells", "H.G.", "*****@*****.**", "Writer", "SciFi", "whatisgithub?", gm)
	msg := socialGraph.NewMessageNode("Will he ever return?")

	edg := socialGraph.NewSocialEdge(1898, "jittered", gm)

	gm.AddNode(hgw)
	gm.AddNode(msg)
	gm.AddEdge(edg)

	gm.Attach(hgw, msg, edg)

	neighbors, err := gm.GetNeighbors(hgw, socialGraph.SocialEdgeConst, socialGraph.SocialNodeConst)

	if err != nil {
		t.Error(err.Error())
	}

	if len(neighbors) != 1 {
		fmt.Printf("***************%v ************\n", neighbors)
		t.Errorf("GetNeighbors Failed - %v neighbors", len(neighbors))
	}

	if err != nil {
		t.Error(err)
	}
}
Esempio n. 2
0
func AddJitter(userID string, jit string) {
	currUser, _ := gm.GetNode(userID, socialGraph.SocialNodeConst)
	jitter := socialGraph.NewMessageNode(jit)
	edge := socialGraph.NewSocialEdge(8182012, jitted_s, gm)
	gm.Attach(currUser, jitter, edge)

}
func initTestEdges(gm spiderDB.GraphBackend) []*socialGraph.SocialEdge {
	var testEdges = []*socialGraph.SocialEdge{
		socialGraph.NewSocialEdge(43, "knows", gm),
		socialGraph.NewSocialEdge(110, "likes", gm),
		socialGraph.NewSocialEdge(79, "hates", gm),
		socialGraph.NewSocialEdge(2, "stalks", gm),
		socialGraph.NewSocialEdge(53, "knows", gm),
		socialGraph.NewSocialEdge(89, "likes", gm),
		socialGraph.NewSocialEdge(12, "hates", gm),
		socialGraph.NewSocialEdge(99, "stalks", gm),
	}
	return testEdges
}
Esempio n. 4
0
func addStreamItem(ctx *web.Context) string {
	JIT := ctx.Params["JIT"]
	userID := ctx.Params["userID"]
	userNode, err := gm.GetNode(userID, socialGraph.SocialNodeConst)
	if err != nil {
		panic(err.Error())
	}
	messageNode := &socialGraph.MessageNode{}
	messageNode.SetText(JIT)
	jitEdge := socialGraph.NewSocialEdge(1, "jitted", gm)
	gm.AddNode(messageNode)
	gm.AddEdge(jitEdge)
	gm.Attach(userNode, messageNode, jitEdge)
	ctx.Params["user"] = userID
	return renderPage(ctx)
}
Esempio n. 5
0
func addFollow(ctx *web.Context) string {
	userID := ctx.Params["userID"]
	newFollow := ctx.Params["newFollow"]
	ctx.Params["user"] = userID

	found, erra := gm.FindNodeWithValue("UserName", newFollow, socialGraph.SocialNodeConst)
	if len(found) != 1 || erra != nil {
		renderPage(ctx)
	}

	usernode, errb := gm.GetNode(userID, socialGraph.SocialNodeConst)
	if errb != nil {
		panic(errb.Error())
	}

	edge := socialGraph.NewSocialEdge(1, "follows", gm)
	gm.AddEdge(edge)
	gm.Attach(usernode, found[0], edge)
	return renderPage(ctx)
}
Esempio n. 6
0
func initDummys() {
	gm = new(spiderDB.GraphManager)
	gm.Initialize()

	// ======= SOCIAL NODES ======= //
	const numdum = 8
	pics := [numdum]string{"http://content8.flixster.com/question/28/64/25/2864258_std.jpg",
		"http://4.bp.blogspot.com/-Q2hjS1dS1R8/T4YXpOfNjOI/AAAAAAAAAxQ/c-V_1FkMYmo/s1600/Bug.jpg",
		"https://encrypted-tbn1.google.com/images?q=tbn:ANd9GcRs5AS0g3hHRdJsO7gBgwu9v1Hr4grtuc_G1dh59MbxEVW3VH-GNw",
		"https://encrypted-tbn3.google.com/images?q=tbn:ANd9GcSJVzRTk5jiGvRIcKQZs-pm4__kMQOWae0WGGl3H32xZCTvci9U",
		"https://encrypted-tbn3.google.com/images?q=tbn:ANd9GcQ6VCAy3UhBqNohPBG1Dr5nVd2WfwTLnINK_pmh0Wo7RUPh7vwpjw",
		"https://encrypted-tbn1.google.com/images?q=tbn:ANd9GcQ677iObh3n9DhnfwvpFUH-ksX9mXv3kyS_h7npytmLACpe9EZX",
		"https://encrypted-tbn3.google.com/images?q=tbn:ANd9GcR94C_rLFc1arqiV_Dmi6LHIQzEVWvOFJg7TxdpdR-PxtVxVLAr",
		"https://encrypted-tbn3.google.com/images?q=tbn:ANd9GcRPaCON4nIzFMqrfCVuWAn8HoD0zH-ir-KovxFxwgy6ocUlYxHJ"}
	bios := [numdum]string{
		"bioTEST",
		"I don't exist",
		"I am from HERE",
		"I am from THERE",
		"I am from A",
		"I am from B",
		"I am from C",
		"I am from D"}
	names := [numdum]string{"nameTEST", "Wedunno", "Joe", "Bill", "Jane", "Sue", "Sally", "Tom"}
	users := [numdum]string{"userTEST", "Whothatis", "jmk", "bill-o-rama", "sparkles", "user1", "user2", "uzaaah"}
	github := [numdum]string{"githubTEST",
		"http://github.com/IAMAUSER",
		"http://github.com/IAMAUSER",
		"http://github.com/IAMAUSER",
		"http://github.com/IAMAUSER",
		"http://github.com/IAMAUSER",
		"http://github.com/IAMAUSER",
		"http://github.com/IAMAUSER"}

	for k, _ := range pics {
		newNode := socialGraph.NewSocialNode(pics[k],
			names[k], users[k], "*****@*****.**",
			bios[k], "skills", github[k], gm)
		gm.AddNode(newNode)
	}

	edgF := socialGraph.NewSocialEdge(1, "follows", gm)
	edgFB := socialGraph.NewSocialEdge(1, "follows", gm)

	gm.AddEdge(edgF)
	gm.AddEdge(edgFB)

	var err error

	node0, err := gm.GetNode("1", socialGraph.SocialNodeConst)
	if err != nil {
		print(err.Error())
	}
	node1, err := gm.GetNode("2", socialGraph.SocialNodeConst)
	if err != nil {
		print(err.Error())
	}
	node2, err := gm.GetNode("3", socialGraph.SocialNodeConst)
	if err != nil {
		print(err.Error())
	}

	gm.Attach(node0, node1, edgF)
	gm.Attach(node0, node2, edgFB)

	// ======= JITS ======= //
	const numMsg = 4
	testJits := make([]*socialGraph.MessageNode, 0)

	jits := [numMsg]string{"JITTER", "JITJITJITTTER", "Jittttaaaaaah", "Jitterbug!"}
	for _, v := range jits {
		newNode := socialGraph.NewMessageNode(v)
		testJits = append(testJits, newNode)
	}

	// ======= JIT EDGES ======= //
	for _, jitter := range testJits {
		edgJit := socialGraph.NewSocialEdge(1, "jitted", gm)
		gm.AddEdge(edgJit)
		gm.Attach(node0, jitter, edgJit)
	}

}