Convert graph to canonical string

I am looking for a way to store graphs as strings. Lines should be used as keys on the map, so two topologically identical graphs will be displayed on the same value on the map. Does anyone know about this algorithm? Tree nodes are marked with duplicate labels.

The program is in java, and the implementation in it will be neat, but any pointers to possible algorithms are appreciated.

+3
source share
5 answers

You can find the corresponding question ...

, . Hopcrofts. , . -. , , , .

. , , .

- , , , . , , , . (, , ) , -.

.., , . ...

  • ( ). (.. node). , ( node, ).

  • () , . node , , . , , . , ( , ) . , , , . , .

EDIT. - , , . , , Hopcrofts.

, . , , , .

, (, ), , , .

, , , - - , , , node / ..

, .

+3

, , , , . . , (:) , , .

, ; , .

+4

gSpan " DFS", , , . gSpan ++ Java.

+1

0

Adjacency, . , , Graph ( , ). Graph, , .

, , hashCode() equals() Graph , .

E: hashCode() equals() - , , . , , , Graph.

If it's equals()too expensive, you should use an adjacency list or matrix, but not just use node names. You must carefully indicate what exactly identifies the individual graphs and vertices (and therefore what makes them equal), and then have your string representation of the adjacency list use these properties instead of the node names. I suggest you write down this specification of your schedule, equal to operation down.

-1
source

Source: https://habr.com/ru/post/1734458/


All Articles