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;
786 graph = kzalloc(sizeof(*graph), GFP_KERNEL);
787 if (!graph)
790 graph->nodes = kcalloc(nodes_count, sizeof(*graph->nodes), GFP_KERNEL);
791 if (!graph->nodes)
793 graph->nodes_count = nodes_count;
795 graph->edges = bitmap_zalloc(nodes_count * nodes_count, GFP_KERNEL);
796 if (!graph->edges)
801 node = &graph->nodes[i++];
805 /* Assemble a temporary graph. Insert edge X->Y in case Y can be
812 pnode = &graph->nodes[i];
813 node = &graph->nodes[j];
817 objagg_tmp_graph_edge_set(graph, i, j);
822 return graph;
825 kfree(graph->nodes);
827 kfree(graph);
831 static void objagg_tmp_graph_destroy(struct objagg_tmp_graph *graph)
833 bitmap_free(graph->edges);
834 kfree(graph->nodes);
835 kfree(graph);
843 struct objagg_tmp_graph *graph;
849 graph = objagg_tmp_graph_create(objagg);
850 if (!graph)
854 * and cross them out of the graph. Save them to the hint list.
856 while ((index = objagg_tmp_graph_node_max_weight(graph)) != -1) {
857 node = &graph->nodes[index];
868 for (j = 0; j < graph->nodes_count; j++) {
869 if (!objagg_tmp_graph_is_edge(graph, index, j))
871 node = &graph->nodes[j];
888 objagg_tmp_graph_destroy(graph);