Dear All,

I'd like to ask is there a way to add a vertex shape/size attribute?

My code:

    igraph_t g;
    igraph_matrix_t coords;
    igraph_vector_t edgelist;

    igraph_matrix_init(&coords, 0, 0);
    igraph_vector_init(&edgelist, getEdgeCount() * 2);

    int plusNodes = 0; // number of nodes that have no edges
    std::map<Node*, int> indexMap;
    for (int i = 0; i < getNodeCount(); ++i) {
        indexMap.insert(std::make_pair(getNodes().at(i).get(), i));
        if (getNodes().at(i)->getInEdges().size() <= 0 &&
                getNodes().at(i)->getOutEdges().size() <= 0) {
            ++plusNodes;
        }
    }

    int ec = 0;
    for (const auto &e : getEdges()) {
        VECTOR(edgelist)[ec++] = indexMap[e->getSource()];
        VECTOR(edgelist)[ec++] = indexMap[e->getDestination()];
    }

    igraph_create(&g, &edgelist, getNodeCount(), IGRAPH_DIRECTED);
    igraph_add_vertices(&g, plusNodes, nullptr);
    igraph_layout_sugiyama(&g, &coords, nullptr, nullptr, nullptr,
          /* hgap = */ 1,
          /* vgap = */ 1,
          /* maxiter = */ 100,
          /* weights = */ nullptr);

    for (int i = 0; i < getNodeCount(); ++i) {
        getNodes().at(i)->getItem()->setX(igraph_matrix_e(&coords, i, 0));
        getNodes().at(i)->getItem()->setY(igraph_matrix_e(&coords, i, 1));
    }

    igraph_vector_destroy(&edgelist);
    igraph_matrix_destroy(&coords);
    igraph_destroy(&g);

This gives result within [0, 5] range. Overlap removal is a must for me so
i need to supply the vertex (rectengular shape) widths and heights to get
correct results.
Is there a way to do this?
I'd also like to supply the port positions for edges if possible. I'm not
sure what attributes igraph uses, and what are just decorations.

Thanks
_______________________________________________
igraph-help mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/igraph-help

Reply via email to