Hacky way to find distance (number of hops) from one node to other nodes

Following that query, I think if we had loops this would be much more precise.
Bellow an idea of a loop generating a shortest path on each person found. And the _weight_ tells us the distance automatically.

Feature: Add foreach() function

{
   var(func: eq(name, "Anurag")) @recurse(depth: 3){
    all as uid
    knows
   }
	targets as var(func: uid(all)){
		name
		city
		age
	}

 q(func: foreach(in: targets, title: name)) {
  A as var(func: eq(name, "Anurag"))
  M as var(func: eq(name, this.name))

   path as shortest(from: uid(A), to: uid(M), numpaths: 2) {
    knows
   }
   path(func: uid(path)) {
     name
   }
 }

}

Result

{
   "data": {
      "q": [
         {
            "name": "Manish",
            "city": "SF",
            "age": "35",
            "path": [
               {
                  "name": "Anurag"
               },
               {
                  "name": "Manish"
               }
            ],
            "_path_": [
               {
                  "knows": {
                     "uid": "0x84"
                  },
                  "uid": "0x83",
                  "_weight_": 1
               }
            ]
         },
         {
            "name": "Chetan",
            "city": "Udaipur",
            "age": "35",
            "path": [
               {
                  "name": "Anurag"
               },
               {
                  "name": "Chetan"
               }
            ],
            "_path_": [
               {
                  "knows": {
                     "uid": "0x85"
                  },
                  "uid": "0x83",
                  "_weight_": 1
               }
            ]
         },
         {
            "name": "Pawan",
            "age": "45",
            "path": [
               {
                  "name": "Anurag"
               },
               {
                  "name": "Manish"
               },
               {
                  "name": "Pawan"
               }
            ],
            "_path_": [
               {
                  "knows": {
                     "knows": {
                        "uid": "0x86"
                     },
                     "uid": "0x84"
                  },
                  "uid": "0x83",
                  "_weight_": 2
               }
            ]
         },
         {
            "name": "Ashish",
            "city": "Varanasi",
            "age": "35",
            "path": [
               {
                  "name": "Anurag"
               },
               {
                  "name": "Chetan"
               },
               {
                  "name": "Ashish"
               }
            ],
            "_path_": [
               {
                  "knows": {
                     "knows": {
                        "uid": "0x87"
                     },
                     "uid": "0x85"
                  },
                  "uid": "0x83",
                  "_weight_": 2
               },
               {
                  "knows": {
                     "knows": {
                        "knows": {
                           "uid": "0x87"
                        },
                        "uid": "0x86"
                     },
                     "uid": "0x84"
                  },
                  "uid": "0x83",
                  "_weight_": 3
               }
            ]
         }
      ]
   }
}