Ranks and structure of graphs