#include "graph_types.h"
#include <cfloat>

void GraphData::update_bounds() {
    if (node_count == 0) {
        min_x = min_y = max_x = max_y = 0.0f;
        return;
    }
    min_x = max_x = nodes[0].x;
    min_y = max_y = nodes[0].y;
    for (int i = 1; i < node_count; ++i) {
        if (nodes[i].x < min_x) min_x = nodes[i].x;
        if (nodes[i].x > max_x) max_x = nodes[i].x;
        if (nodes[i].y < min_y) min_y = nodes[i].y;
        if (nodes[i].y > max_y) max_y = nodes[i].y;
    }
}

int GraphData::find_node(uint32_t id) const {
    for (int i = 0; i < node_count; ++i) {
        if (nodes[i].id == id) return i;
    }
    return -1;
}
