#include "graph_types.h"

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_by_user_data(uint64_t user_data) const {
    for (int i = 0; i < node_count; ++i) {
        if (nodes[i].user_data == user_data) return i;
    }
    return -1;
}
