Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
topological_sort.h
Go to the documentation of this file.
1/*
2 This file is part of Ansel,
3 Copyright (C) 2026 Aurélien PIERRE.
4
5 Ansel is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 Ansel is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with Ansel. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#ifndef DT_MATH_TOPOLOGICAL_SORT_H
20#define DT_MATH_TOPOLOGICAL_SORT_H
21
79#include <glib.h>
80
81G_BEGIN_DECLS
82
87
107
122{
123 const char *id;
124 char *tag;
125 GList *previous;
126 void *user_data;
127};
128
137typedef void (*dt_node_user_data_destroy_t)(void *data);
138
170int flatten_nodes(GList *input_nodes, GList **out_nodes);
171
200int topological_sort(GList *nodes, GList **sorted, GList **cycle_out);
201
231 GList *nodes,
232 GHashTable *node_ht,
233 dt_node_user_data_destroy_t user_destroy);
234
244
245G_END_DECLS
246
247#endif // DT_MATH_TOPOLOGICAL_SORT_H
typedef void((*dt_cache_allocate_t)(void *userdata, dt_cache_entry_t *entry))
One constraint set relative to the node that owns it.
Directed graph node.
void dt_digraph_cleanup_full(GList *nodes, GHashTable *node_ht, dt_node_user_data_destroy_t user_destroy)
Free a canonical graph (nodes, constraints, ids) in one call.
void(* dt_node_user_data_destroy_t)(void *data)
Optional destructor for node payloads.
int flatten_nodes(GList *input_nodes, GList **out_nodes)
Canonicalize / merge duplicated nodes by id.
dt_digraph_node_t * dt_digraph_node_new(const char *id)
Allocate and initialize a new digraph node with the given id.
int topological_sort(GList *nodes, GList **sorted, GList **cycle_out)
Perform a topological sort using depth-first search (DFS).