grafo.jl

Solution workflow automatic generator for `boris` using Graphs.jl.

using Graphs


The arterial tree is specified as a simple_graph with 13 nodes and vessels (aka edges) are added by hand (for now) through add_edge!.

g = simple_graph(13)

add_edge!(g, 1,2)
add_edge!(g, 2,3)
add_edge!(g, 2,4)
add_edge!(g, 3,5)
add_edge!(g, 3,6)
add_edge!(g, 4,11)
add_edge!(g, 4,7)
add_edge!(g, 5,8)
add_edge!(g, 5,9)
add_edge!(g, 6,10)
add_edge!(g, 6,11)
add_edge!(g, 7,12)
add_edge!(g, 11,13)


Function edges returns a list of iterable edges.

e = edges(g)


Each edge is evaluated starting from the 1st; current edge index is stored as i, its source node is s and its target node is t.

for i in 1:length(e)
	s = source(e[i])
	t = target(e[i])


If the source node is the first in the arterial tree, the inlet boundary condtion is applied.

	if s == 1
		@printf "edge %i - source %i -> setInletBC \n" i s
	end


Once the source node is processed, the edge (vessel) is solved by means of Godunov’s method.

	@printf "edge %i - solve \n" i


If the target node is a peripheral node, the outlet boundary condition is applied.

	if out_degree(t, g) == 0
		@printf "edge %i - target %i -> setOutletBC \n" i t


If from the target t node is the source node of a new edge, a check is done to establish wether t is a conjunction node or an anastomosis node. A conjunction is found when the out_degree of t is equal to 1, otherwise is an anastomosis.

	elseif out_degree(t, g) == 1


The conjunction is solved calling the joinVessels routine with parent and daughter indices.

		if length(in_edges(t, g)) == 1
			o = out_edges(t, g)
			@printf "edge %i -> conjunction %i - %i \n" i i edge_index(o[1],g)


Before solving the anastomosis a check is done on the current edge index i. If i is higher than the index of the other parent edge, it means that both parent vessel have been already solved, thus the anastomosis can be solved as well.

		else
			es = in_edges(t, g)
			if i == max(edge_index(es[1],g), edge_index(es[2], g))
				@printf "node %i -> anastomosis(%i, %i, %i) \n" t edge_index(es[1],g) edge_index(es[2], g) edge_index(out_edges(t,g)[1])
			end
		end


A bifurcation is found when the out_degree of t is 2. It is solved as soon as it is found because the parent vessel is already solved for sure.

	elseif out_degree(t, g) == 2
		@printf "node %i -> bifurcation(%i, %i, %i) \n" t i edge_index(out_edges(t,g)[1]) edge_index(out_edges(t,g)[2])

	end
end