MCPcopy Create free account
hub / github.com/dgraph-io/dgraph / TestKShortestPathDepth

Function TestKShortestPathDepth

query/query3_test.go:559–684  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

557}
558
559func TestKShortestPathDepth(t *testing.T) {
560 // Shortest path between 1 and 1000 is the path 1 => 31 => 1001 => 1000
561 // but if the depth is less than 3 then there is no direct path between
562 // 1 and 1000. Also if depth >=5 there is another path
563 // 1 => 31 => 1001 => 1003 => 1002 => 1000
564 query := `
565 query test ($depth: int, $numpaths: int) {
566 path as shortest(from: 1, to: 1000, depth: $depth, numpaths: $numpaths) {
567 follow
568 }
569 me(func: uid(path)) {
570 name
571 }
572 }`
573
574 emptyPath := `{"data": {"me":[]}}`
575
576 onePath := `{
577 "data": {
578 "me": [
579 {"name": "Michonne"},
580 {"name": "Andrea"},
581 {"name": "Bob"},
582 {"name": "Alice"}
583 ],
584 "_path_": [
585 {
586 "follow": {
587 "follow": {
588 "follow": {
589 "uid": "0x3e8"
590 },
591 "uid": "0x3e9"
592 },
593 "uid": "0x1f"
594 },
595 "uid": "0x1",
596 "_weight_": 3
597 }
598 ]
599 }
600 }`
601 twoPaths := `{
602 "data": {
603 "me": [
604 {"name": "Michonne"},
605 {"name": "Andrea"},
606 {"name": "Bob"},
607 {"name": "Alice"}
608 ],
609 "_path_": [
610 {
611 "follow": {
612 "follow": {
613 "follow": {
614 "uid": "0x3e8"
615 },
616 "uid": "0x3e9"

Callers

nothing calls this directly

Calls 2

processQueryWithVarsFunction · 0.70
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…