ladanyi@1024: #include ladanyi@1024: ladanyi@1024: using namespace lemon; ladanyi@1024: ladanyi@1024: typedef ListGraph Graph; ladanyi@1024: typedef Graph::NodeIt NodeIt; ladanyi@1024: typedef Graph::EdgeIt EdgeIt; ladanyi@1024: ladanyi@1024: class MyEntity { ladanyi@1024: public: ladanyi@1024: Graph &g; ladanyi@1024: Graph::NodeMap selected; ladanyi@1024: int edges; ladanyi@1024: int covered_edges; ladanyi@1024: ladanyi@1024: MyEntity(Graph &_g) : g(_g), selected(_g) {} ladanyi@1024: MyEntity(MyEntity& e) : g(e.g), selected(e.g) { ladanyi@1024: for (NodeIt n(g); n != INVALID; ++n) { ladanyi@1024: selected[n] = e.selected[n]; ladanyi@1024: } ladanyi@1024: edges = e.edges; ladanyi@1024: covered_edges = e.covered_edges; ladanyi@1024: } ladanyi@1024: double getCost() { ladanyi@1024: return (double) (edges - covered_edges); ladanyi@1024: } ladanyi@1024: void mutate() { ladanyi@1024: ladanyi@1024: } ladanyi@1024: void revert() { ladanyi@1024: ladanyi@1024: } ladanyi@1024: }; ladanyi@1024: ladanyi@1024: int main() { ladanyi@1024: Graph g; ladanyi@1024: // beolvasas ladanyi@1024: MyEntity ent(g); ladanyi@1024: ladanyi@1024: // kezdeti lefedes generalasa ladanyi@1024: int nn = 0; ladanyi@1024: for (NodeIt n(g); n != INVALID; ++n) { ladanyi@1024: ent.selected[n] = false; ladanyi@1024: nn++; ladanyi@1024: } ladanyi@1024: // k db random node kivalasztasa ladanyi@1024: ladanyi@1024: int i = 0, j = 0; ladanyi@1024: for (EdgeIt e(g); e != INVALID; ++e) { ladanyi@1024: i++; ladanyi@1024: if ((ent.selected[g.source(e)]) || (ent.selected[g.target(e)])) { ladanyi@1024: j++; ladanyi@1024: } ladanyi@1024: } ladanyi@1024: ent.edges = i; ladanyi@1024: ent.covered_edges = j; ladanyi@1024: ladanyi@1024: }