anniequinn / AHgen

AHgen is a software code written in R. It is designed to generate, analyse, and compare five-level hierarchical networks called “Abstraction Hierarchies”. AHgen may used to analyse Abstraction Hierarchies in any domain or at any scale.
MIT License
2 stars 2 forks source link

vis_AH_layout function attribute value mismatch #4

Open rmcneilly opened 1 week ago

rmcneilly commented 1 week ago

When using the vis_AH_layout function I get the following error:

Error in i_set_vertex_attr(x, attr(value, "name"), index = value, value = attr(value,  : 
  Length of new attribute value must be 1 or 149, the number of target vertices, not 148

This occurs for both my own data and the USAH input in the package. In both instances the attribute value is one less than the target. For my dataset, the edgelist and vInfo are both 148 and all values match, so there is no discrepancies between them. My dataset also works with some of the other functions in the package.

Here is what I am working with at the moment:

dh = read_adjMat("myspreadsheet.xlsx")

dv = dh %>% select(level, levelName_full, levelName, Node)

de = dh %>% adjMat_to_edgelist(vInfo = dv); de

visKey =
  tribble(
    ~layer, ~min, ~max, ~addR, ~r,
    1,250,290,0,1,
    2,250,290,0,2,
    3,260,280,0,3,
    4,260,280,0,4,
    5,250,290,0,5)

visKey

plot_layout = 
  vis_AH_layout(edgelist = de,
                vInfo = dv,
                minSpacing = 0, 
                maxSpacing = 1000,
                key = visKey)

plot_layout

Any assistance is appreciate! My R knowledge is fairly basic and I feel like I have exhausted my troubleshooting abilities.

Edit: I am able to get the function to work with a simple one node per level abstraction matrix. Still unclear why it is not working for larger models.

rmcneilly commented 1 week ago

The issue seems to be due to the dummy vertex added when there is more than one functional purposes (level 1 node) in the AM. I was able to produce the plot outputs when I removed all functional purposes, bar one, from my AM.

There is a separate issue with the call to igraph::graph.data.frame in _edgelist_to_igraph_ function which requires updating to igraph::graph_from_data_frame.