Region adjacency graph

make_region_adjacency_graph_from_labelisation(…)

Create a region adjacency graph (rag) of a vertex labelled graph.

make_region_adjacency_graph_from_graph_cut(…)

Create a region adjacency graph (rag) from a graph cut.

rag_back_project_vertex_weights(graph, …)

Projects rag vertex weights onto original graph vertices.

rag_back_project_edge_weights(graph, …)

Projects rag edge weights onto original graph edges.

rag_accumulate_on_vertices(rag, accumulator, …)

Weights rag vertices by accumulating values from the vertex weights of the original graph.

rag_accumulate_on_edges(rag, accumulator, …)

Weights rag edges by accumulating values from the edge weights of the original graph.

make_region_adjacency_graph_from_labelisation(graph, vertex_labels)[source]

Create a region adjacency graph (rag) of a vertex labelled graph. Each maximal connected set of vertices having the same label is a region. Each region is represented by a vertex in the rag. There is an edge between two regions of labels \(l_1\) and \(l_2\) in the rag iff there exists an edge linking two vertices of labels \(l_1\) and \(l_2\) int he original graph.

Parameters
  • graph – input graph

  • vertex_labels – vertex labels on the input graph

Returns

a region adjacency graph (Concept CptRegionAdjacencyGraph)

make_region_adjacency_graph_from_graph_cut(graph, edge_weights)[source]

Create a region adjacency graph (rag) from a graph cut. Two vertices \(v_1\), \(v_2\) are in the same region if there exists a \(v_1v_2\)-path composed of edges weighted 0. Each region is represented by a vertex in the rag. There is an edge between two regions of labels \(l_1\) and \(l_2\) in the rag iff there exists an edge linking two vertices of labels \(l_1\) and \(l_2\) int he original graph.

Parameters
  • graph – input graph

  • edge_weights – edge weights on the input graph, non zero weights are part of the cut

Returns

a region adjacency graph (Concept CptRegionAdjacencyGraph)

rag_back_project_vertex_weights(graph, vertex_weights)[source]

Projects rag vertex weights onto original graph vertices. The result is an array weighting the vertices of the original graph of the rag such that: for any vertex \(v\) of the original graph, its weight is equal to the weight of the vertex of the rag that represents the region that contains \(v\).

For any vertex index \(i\), \(result[i] = rag\_vertex\_weight[rag\_vertex_map[i]]\)

Parameters
  • graph – input region adjacency graph

  • vertex_weights – vertex weights on the input region adjacency graph

Returns

vertex weights on the original graph

rag_back_project_edge_weights(graph, edge_weights)[source]

Projects rag edge weights onto original graph edges. The result is an array weighting the edges of the original graph of the rag such that: for any edge \(e\) of the original graph, its weight is equal to the weight of the edge of the rag that represents that links the two regions containing the extremities of \(e\). If no such edge exists (if the extremities of \(e\) are in the same region), its value is 0.

For any edge index \(ei\), \(result[ei] = rag\_edge\_weight[rag\_edge\_map[ei]]\) if \(rag\_edge\_map[ei] != -1\) and 0 otherwise.

Parameters
  • graph – input region adjacency graph

  • edge_weights – edge weights on the input region adjacency graph

Returns

edge weights on the original graph

rag_accumulate_on_vertices(rag, accumulator, vertex_weights)[source]

Weights rag vertices by accumulating values from the vertex weights of the original graph.

For any vertex index \(i\) of the rag, \(result[i] = accumulator(\{vertex\_weights[j] | rag\_vertex\_map[j] == i\})\)

Parameters
  • rag – input region adjacency graph (Concept RegionAdjacencyGraph)

  • vertex_weights – vertex weights on the original graph

  • accumulator – see Accumulators

Returns

vertex weights on the region adjacency graph

rag_accumulate_on_edges(rag, accumulator, edge_weights)[source]

Weights rag edges by accumulating values from the edge weights of the original graph.

For any edge index \(ei\) of the rag, \(result[ei] = accumulate(\{edge\_weights[j] | rag\_edge\_map[j] == ei\})\)

Parameters
  • rag – input region adjacency graph (Concept RegionAdjacencyGraph)

  • edge_weights – edge weights on the original graph

  • accumulator – see Accumulators

Returns

edge weights on the region adjacency graph