def compute_percent_correct(data):
  """Compute the ratio of edges connecting two nodes with the same label.

  Args:
    data: A GraphDataset object.

  Returns:
    A float representing the ratio of edges among all graph edges that are
    connecting nodes with similar labels.
  """
  correct_edges = 0
  for edge in data.edges:
    if data.get_labels(edge.src) == data.get_labels(edge.tgt):
      correct_edges = correct_edges + 1
  total_edges = len(data.edges)
  return float(correct_edges) / total_edges, correct_edges, total_edges