import java.util.*;

public class AttackGraph {
    public static class Edge {
        public String target;
        public int weight;
        public Edge(String target, int weight) {
            this.target = target;
            this.weight = weight;
        }
    }

    public Map<String, List<Edge>> adjList = new HashMap<>();

    public void addEdge(String from, String to, String ip) {
        adjList.putIfAbsent(from, new ArrayList<>());
        adjList.putIfAbsent(to, new ArrayList<>());
        
        boolean found = false;
        int currentWeight = 1;

        for (Edge e : adjList.get(from)) {
            if (e.target.equals(to)) {
                e.weight++;
                currentWeight = e.weight;
                found = true;
                break;
            }
        }
        if (!found) {
            adjList.get(from).add(new Edge(to, 1));
        }

        int totalEdges = 0;
        for (List<Edge> edges : adjList.values()) {
            totalEdges += edges.size();
        }

        System.out.println("[ATTACK GRAPH] New edge added:");
        System.out.println("  → Source node: " + from);
        System.out.println("  → Target node: " + to);
        System.out.println("  → IP responsible: " + ip);
        System.out.println("  → Edge weight: " + currentWeight + " (frequency based)");
        System.out.println("  → Total nodes in graph: " + adjList.size());
        System.out.println("  → Total edges in graph: " + totalEdges);
    }
}
