0

I have a graph (Fig1)

enter image description here

which has four attributes in T-SQL:

Id int, StartNodeID int, EndNodeID int, EdgeGeometry Geometry

I want to extract the id of those edges that have a connection or path to the specific node. For example, the result for the node = 7 should be as below:

EdgeId
------------------------------------------
6, 5, 4, 3, 2, 1, 7, 12, 13, 8, 9, 10, 11

Can anyone help me that how can I implement it in SQL Server?

Regards

Fig1 Fig2

podiluska
  • 50,950
  • 7
  • 98
  • 104
  • Why do the results have to be a single row? Can't they be one edge per row *(with a sequence identifier to allow them to be kept in appropriate order)*? Also, why `4 then 3` rather than `4 then 2`? Because you also have `2 then 1` rather than `2 then 7`, but `7 then 12` rather than `7 then 8`... *(Explicitly, what order should this walk when there is a choice? Lowest edge id first? Lowest node id first? Your answer seems very inconsistent in that regard.)* – MatBailie Jan 07 '18 at 16:35
  • Thanks for the comment. As a matter of fact, it doesn't really need to be in one row, the output results are important, whether be one edge per row or something else. For the second part of your question, I just need those edges have any connection to the node =7. So, as you mention, we can have different orders for the outputs such as 6, 5, 4, 2, 1, 3, ...Again, I just need these outputs @MatBailie. – Mohammad Kazemi-Beydokhti Jan 08 '18 at 05:03

0 Answers0