Lines Matching refs:graph

710 static int objagg_tmp_graph_edge_index(struct objagg_tmp_graph *graph,
713 return index * graph->nodes_count + parent_index;
716 static void objagg_tmp_graph_edge_set(struct objagg_tmp_graph *graph,
719 int edge_index = objagg_tmp_graph_edge_index(graph, index,
722 __set_bit(edge_index, graph->edges);
725 static bool objagg_tmp_graph_is_edge(struct objagg_tmp_graph *graph,
728 int edge_index = objagg_tmp_graph_edge_index(graph, index,
731 return test_bit(edge_index, graph->edges);
734 static unsigned int objagg_tmp_graph_node_weight(struct objagg_tmp_graph *graph,
737 struct objagg_tmp_node *node = &graph->nodes[index];
745 for (j = 0; j < graph->nodes_count; j++) {
746 if (!objagg_tmp_graph_is_edge(graph, index, j))
748 node = &graph->nodes[j];
756 static int objagg_tmp_graph_node_max_weight(struct objagg_tmp_graph *graph)
764 for (i = 0; i < graph->nodes_count; i++) {
765 node = &graph->nodes[i];
768 weight = objagg_tmp_graph_node_weight(graph, i);
780 struct objagg_tmp_graph *graph;
787 graph = kzalloc(sizeof(*graph), GFP_KERNEL);
788 if (!graph)
791 graph->nodes = kcalloc(nodes_count, sizeof(*graph->nodes), GFP_KERNEL);
792 if (!graph->nodes)
794 graph->nodes_count = nodes_count;
798 graph->edges = kzalloc(alloc_size, GFP_KERNEL);
799 if (!graph->edges)
804 node = &graph->nodes[i++];
808 /* Assemble a temporary graph. Insert edge X->Y in case Y can be
815 pnode = &graph->nodes[i];
816 node = &graph->nodes[j];
820 objagg_tmp_graph_edge_set(graph, i, j);
825 return graph;
828 kfree(graph->nodes);
830 kfree(graph);
834 static void objagg_tmp_graph_destroy(struct objagg_tmp_graph *graph)
836 kfree(graph->edges);
837 kfree(graph->nodes);
838 kfree(graph);
846 struct objagg_tmp_graph *graph;
852 graph = objagg_tmp_graph_create(objagg);
853 if (!graph)
857 * and cross them out of the graph. Save them to the hint list.
859 while ((index = objagg_tmp_graph_node_max_weight(graph)) != -1) {
860 node = &graph->nodes[index];
871 for (j = 0; j < graph->nodes_count; j++) {
872 if (!objagg_tmp_graph_is_edge(graph, index, j))
874 node = &graph->nodes[j];
891 objagg_tmp_graph_destroy(graph);