A cyber security problem is considered in a networked system formulated as a resilient graph problem based on a game theoretic approach. The connectivity of the underlying graph of the network system is reduced by an attacker who removes some of the edges whereas the defender attempts to recover them. Both players are subject to energy constraints so that their actions are restricted and cannot be performed continuously. We provide a subgame perfect equilibrium analysis and fully characterize the optimal strategies for the attacker and the defender in terms of edge connectivity and the number of connected components of the graph. The resilient graph game is then applied to the multiagent consensus problem. We study how the attacks and the recovery on the edges affect the consensus process.