Conversation
Rot127
left a comment
There was a problem hiding this comment.
Looks already way way better then before! Thanks a lot.
Some questions you might have already considered.
- Should the graph's API mostly work on Node pointers or the node ids? Having both would be nice. If the node content doesn't matter to the user. But working on pointers is fine for me as well for now.
- Runtime complexity for getting neighbors. Please let's not clone the nodes every time the neighbor list is requested. This doesn't scale well. Instead a read only
RzIteratorover the lists/matrix is a better fit I think. - Could the elements in the List based graph implementation contain edges? It would maybe reduce internal complexity getting the neighbors. Especially for directed graphs.
|
You can checkout
You make a good point there. Considering code complexity (meaning: many lines of code) vs. low runtime complexity. If you don't want to add an edge list for now (because too much work/ too many things to consider), it is fine. cc @wargio |
|
agreed with @Rot127 I think it is ok to have first an implementation that works, then we can improve the execution time. |
|
@Heersin have you had any updates since? |
|
@Heersin ping |
e636b1c to
3a8c06e
Compare
Please, yes! My use case is a control flow graph. Each node is a basic block (a sequence of instructions with the last instruction being a branch (jump or call)). Now, the edges of the CFG are the jumps. Obvious. Then I would have edges of type I for normal branches, and edges of type II for "follows call". |
|
i agree, it makes sense to support generic graphs with whatever data provided. |
3a8c06e to
e965993
Compare
notxvilka
left a comment
There was a problem hiding this comment.
It probably makes sense to split graph into two files: implementation and algorithms.
librz/util/graph.c
Outdated
| return NULL; | ||
| } | ||
|
|
||
| RZ_API void rz_graph_free_new(RZ_NULLABLE RZ_OWN RzGraphNew *g) { |
There was a problem hiding this comment.
| RZ_API void rz_graph_free_new(RZ_NULLABLE RZ_OWN RzGraphNew *g) { | |
| RZ_API void rz_graph_free(RZ_NULLABLE RZ_OWN RzGraphNew *g) { |
There was a problem hiding this comment.
Just so we don't forget about it :)
e965993 to
7987507
Compare
DONE |
|
@Heersin Please replace it here, so the test coverage is higher. |
594b106 to
b29c7b1
Compare
|
Still Some DB fixing WIP |
| * \param visitor callbacks | ||
| */ | ||
| static void dfs_edge_policy(RzGraph *g, RzGraphNode *from, RzGraphNode *to, ut8 *edge_color, RzGraphVisitor *visitor) { | ||
| // assert g, from, to, edge_color, visitor NON NULL |
There was a problem hiding this comment.
You could just use rz_return_if_fail()
| dfs_edge_policy(g, from, to, color, visitor); | ||
| } | ||
|
|
||
| // CORLOR changes |
5362d9b to
aefe77a
Compare
Add comments Basic support for list and matrix based graph refactor Add rz_graph_*_new node and edge API Modify calling for rz graph edge data Add dfs and visitor mode Add new get nth neighbours Add unit test and wrapper for get edges Bug fixed and unit test Solve TODO about better semantic of get nodes Doc RZ_API and other functions, split impl to new files [cannot build] remove old graph impl and rename new graph API
Update Wrapper for graph identifier Ordered Nodes in graph drawable Fix icfg and several agraph refactor issues Use kahn to get topo sort in assign_layers Introduce khan for assign_layer and find DAG cycle and backedges in algorithm
17793c9 to
f89f79d
Compare
notxvilka
left a comment
There was a problem hiding this comment.
Missing type comment at <rizin/librz/util/graph_impl.c:1547:59> (token is not a comment)
Missing type comment at <rizin/librz/util/graph_impl.c:1564:46> (token is not a comment)
Missing type comment at <rizin/librz/util/graph_impl.c:1573:46> (token is not a comment)
Missing type comment at <rizin/librz/util/graph_impl.c:1583:46> (token is not a comment)
Missing type comment at <rizin/librz/util/graph_impl.c:1593:46> (token is not a comment)
Missing type comment at <rizin/librz/util/graph_impl.c:1603:77> (token is not a comment)
Missing type comment at <rizin/librz/util/graph_impl.c:1613:61> (token is not a comment)
Missing type comment at <rizin/librz/util/graph_impl.c:1622:60> (token is not a comment)
Missing type comment at <rizin/librz/util/graph_impl.c:1631:65> (token is not a comment)
Missing type comment at <rizin/librz/util/graph_impl.c:1640:64> (token is not a comment)
Missing type comment at <rizin/librz/util/graph_impl.c:1649:54> (token is not a comment)
Missing type comment at <rizin/librz/util/graph_impl.c:1658:53> (token is not a comment)
Missing type comment at <rizin/librz/util/graph_impl.c:1667:87> (token is not a comment)
Missing type comment at <rizin/librz/util/graph_algorithm.c:54:38> (token is not a comment)
Missing type comment at <rizin/librz/util/graph_algorithm.c:89:42> (token is not a comment)
Missing type comment at <rizin/librz/util/graph_algorithm.c:120:37> (token is not a comment)
Missing type comment at <rizin/librz/util/graph_algorithm.c:184:31> (token is not a comment)
Missing type comment at <rizin/librz/util/graph_algorithm.c:239:35> (token is not a comment)
Missing type comment at <rizin/librz/util/graph_algorithm.c:254:43> (token is not a comment)
Missing type comment at <rizin/librz/util/graph_algorithm.c:270:45> (token is not a comment)
Missing type comment at <rizin/librz/util/graph_algorithm.c:286:53> (token is not a comment)
Missing type comment at <rizin/librz/util/graph_algorithm.c:296:43> (token is not a comment)
Missing type comment at <rizin/librz/util/graph_algorithm.c:348:77> (token is not a comment)
Missing type comment at <rizin/librz/util/graph_algorithm.c:462:87> (token is not a comment)
...
|
Also compilation on Windows should be fixed: |
|
Superseded by #6152 |
Your checklist for this pull request
Detailed description
working on implement functions
Add more graph representation for rizin, see #4231
Test plan
Closing issues
...