gama-platform / gama

Main repository for developing the 2024+ versions of GAMA
https://gama-platform.org
GNU General Public License v3.0
12 stars 5 forks source link

[Graph] odd outcomes using node_species argument of operators that generates graph #139

Closed chapuisk closed 3 months ago

chapuisk commented 3 months ago

Describe the bug Operators to generate graph (such as small world, scale free and the like) make it possible to specify the species of the node, i.e. argument node_species. Doing so leads to diverse odd outcomes: more nodes than agent of species created, node (vertice) that are actually not from defined species, spatial representation do not match, etc.

To Reproduce Steps to reproduce the behavior:

  1. Copy past this simple model example:

    
    global {
    
    graph<a,unknown> g;
    init {
    
        g <- generate_random_graph(10,10,false,a);
    
        write g.vertices;
        write g.edges;
    
        g <- as_spatial_graph(g);
    
        write g.vertices;
        write g.edges;
    
        ask a {
            write sample(g contains_vertex self);
            write sample(g neighbors_of self);
        }
    
    }

}

species a { aspect default {draw circle(1) color:#grey;} }

experiment xp { output { display main { species a; graphics edges {loop e over:g.edges {draw geometry(e) color:#black;}} } } }


2. Execute model
3. See in console that 
5. See error

**Expected behavior**
Being able to build a graph using available methods without having to go through another operator (as_spatial_graph), having to maintain the link between inner graph representation of nodes and edges and my node species, being able to display it right away, etc.

**Desktop (please complete the following information):**
 - OS: macOS Sonoma
 - GAMA version: 1.9.3

**Side note**
It is counter intuitive to be forced to turn generated graph into a spatial graph to be able to manipulate and display it
lesquoyb commented 3 months ago

I also noticed some weird code in graphs while cleaning up the code base (see for example here a property was used in some graph algorithms but actually never set) I think that part has been modified many many times and would benefit from some refactoring

ptaillandier commented 3 months ago

@chapuisk to be tested, but it should be fixed