Skip to main content
edited tags
Link
added 1 character in body
Source Link

The following Code highlighthighlights the breadth-first scan tree

g = GridGraph[{3, 5}, VertexSize -> {5 -> Medium}]
Reap[BreadthFirstScan[g, 5, {"FrontierEdge" -> Sow}]]

This produces the output (where <-> represents undirected edge).

{{2, 5, 2, 5, 5, 5, 4, 5, 6, 7, 8, 9, 10, 11, 12}, {{5 <-> 2, 5 <-> 4, 5 <-> 6, 5 <-> 8, 2 <-> 1, 2 <-> 3, 4 <-> 7, 6 <-> 9, 8 <-> 11, 7 <-> 10, 9 <-> 12, 11 <-> 14, 10 <-> 13, 12 <-> 15}}}

I have read up on reap and sow and understand the second list. The first list which is supposed to capture the final outcome of the compound expression however is not clear.

What do the vertices in this first list represent (in the context of reap and sow for this particular application)?

{2, 5, 2, 5, 5, 5, 4, 5, 6, 7, 8, 9, 10, 11, 12}

In a breadth first scan I would have expected the final outcomes to be more closely related to the order of visiting nodes in the scan.

I guess my question is: isIs this output consistent with what ought to be produced in a reap and sow context for this particular application? And if so, can you clarify how this is the case (in terms of reap and sow functioning)?

The following Code highlight the breadth-first scan tree

g = GridGraph[{3, 5}, VertexSize -> {5 -> Medium}]
Reap[BreadthFirstScan[g, 5, {"FrontierEdge" -> Sow}]]

This produces the output (where <-> represents undirected edge).

{{2, 5, 2, 5, 5, 5, 4, 5, 6, 7, 8, 9, 10, 11, 12}, {{5 <-> 2, 5 <-> 4, 5 <-> 6, 5 <-> 8, 2 <-> 1, 2 <-> 3, 4 <-> 7, 6 <-> 9, 8 <-> 11, 7 <-> 10, 9 <-> 12, 11 <-> 14, 10 <-> 13, 12 <-> 15}}}

I have read up on reap and sow and understand the second list. The first list which is supposed to capture the final outcome of the compound expression however is not clear.

What do the vertices in this first list represent (in the context of reap and sow for this particular application)?

{2, 5, 2, 5, 5, 5, 4, 5, 6, 7, 8, 9, 10, 11, 12}

In a breadth first scan I would have expected the final outcomes to be more closely related to the order of visiting nodes in the scan.

I guess my question is: is this output consistent with what ought to be produced in a reap and sow context for this particular application? And if so, can you clarify how this is the case (in terms of reap and sow functioning)?

The following Code highlights the breadth-first scan tree

g = GridGraph[{3, 5}, VertexSize -> {5 -> Medium}]
Reap[BreadthFirstScan[g, 5, {"FrontierEdge" -> Sow}]]

This produces the output (where <-> represents undirected edge).

{{2, 5, 2, 5, 5, 5, 4, 5, 6, 7, 8, 9, 10, 11, 12}, {{5 <-> 2, 5 <-> 4, 5 <-> 6, 5 <-> 8, 2 <-> 1, 2 <-> 3, 4 <-> 7, 6 <-> 9, 8 <-> 11, 7 <-> 10, 9 <-> 12, 11 <-> 14, 10 <-> 13, 12 <-> 15}}}

I have read up on reap and sow and understand the second list. The first list which is supposed to capture the final outcome of the compound expression however is not clear.

What do the vertices in this first list represent (in the context of reap and sow for this particular application)?

{2, 5, 2, 5, 5, 5, 4, 5, 6, 7, 8, 9, 10, 11, 12}

In a breadth first scan I would have expected the final outcomes to be more closely related to the order of visiting nodes in the scan.

Is this output consistent with what ought to be produced in a reap and sow context for this particular application? And if so, can you clarify how this is the case (in terms of reap and sow functioning)?

Source Link

Reap and sow for BreadthFirstSearch

The following Code highlight the breadth-first scan tree

g = GridGraph[{3, 5}, VertexSize -> {5 -> Medium}]
Reap[BreadthFirstScan[g, 5, {"FrontierEdge" -> Sow}]]

This produces the output (where <-> represents undirected edge).

{{2, 5, 2, 5, 5, 5, 4, 5, 6, 7, 8, 9, 10, 11, 12}, {{5 <-> 2, 5 <-> 4, 5 <-> 6, 5 <-> 8, 2 <-> 1, 2 <-> 3, 4 <-> 7, 6 <-> 9, 8 <-> 11, 7 <-> 10, 9 <-> 12, 11 <-> 14, 10 <-> 13, 12 <-> 15}}}

I have read up on reap and sow and understand the second list. The first list which is supposed to capture the final outcome of the compound expression however is not clear.

What do the vertices in this first list represent (in the context of reap and sow for this particular application)?

{2, 5, 2, 5, 5, 5, 4, 5, 6, 7, 8, 9, 10, 11, 12}

In a breadth first scan I would have expected the final outcomes to be more closely related to the order of visiting nodes in the scan.

I guess my question is: is this output consistent with what ought to be produced in a reap and sow context for this particular application? And if so, can you clarify how this is the case (in terms of reap and sow functioning)?