code: def random_homo_graphbolt_graph(
      test_dir,
      dataset_name,
      num_nodes,
      num_edges,
      num_classes,
      edge_fmt="csv",
  ):
      """Generate random graphbolt version homograph"""
      # Generate random edges.
      nodes = np.repeat(np.arange(num_nodes), 5)
      neighbors = np.random.randint(0, num_nodes, size=(num_edges))
      edges = np.stack([nodes, neighbors], axis=1)
      os.makedirs(os.path.join(test_dir, "edges"), exist_ok=True)
      assert edge_fmt in ["numpy", "csv"], print(
          "only numpy and csv are supported for edges."
      )
      if edge_fmt == "csv":
          # Wrtie into edges/edge.csv
          edges = pd.DataFrame(edges, columns=["src", "dst"])
          edge_path = os.path.join("edges", "edge.csv")
          edges.to_csv(
              os.path.join(test_dir, edge_path),
              index=False,
              header=False,
          )
      else:
          # Wrtie into edges/edge.npy
          edges = edges.T
          edge_path = os.path.join("edges", "edge.npy")
          np.save(os.path.join(test_dir, edge_path), edges)
  
      # Generate random graph edge-feats.
      edge_feats = np.random.rand(num_edges, num_classes)
      os.makedirs(os.path.join(test_dir, "data"), exist_ok=True)
      edge_feat_path = os.path.join("data", "edge-feat.npy")
      np.save(os.path.join(test_dir, edge_feat_path), edge_feats)
  
      # Generate random node-feats.
      if num_classes == 1:
          node_feats = np.random.rand(num_nodes)
      else:
          node_feats = np.random.rand(num_nodes, num_classes)
      node_feat_path = os.path.join("data", "node-feat.npy")
      np.save(os.path.join(test_dir, node_feat_path), node_feats)
  
      # Generate train/test/valid set.
      assert num_nodes % 4 == 0, "num_nodes must be divisible by 4"
      each_set_size = num_nodes // 4
      os.makedirs(os.path.join(test_dir, "set"), exist_ok=True)
      train_pairs = (
          np.arange(each_set_size),
          np.arange(each_set_size, 2 * each_set_size),
      )
      train_data = np.vstack(train_pairs).T.astype(np.int64)
      train_path = os.path.join("set", "train.npy")
      np.save(os.path.join(test_dir, train_path), train_data)
  
      validation_pairs = (
          np.arange(each_set_size, 2 * each_set_size),
          np.arange(2 * each_set_size, 3 * each_set_size),
      )
      validation_data = np.vstack(validation_pairs).T.astype(np.int64)
      validation_path = os.path.join("set", "validation.npy")
      np.save(os.path.join(test_dir, validation_path), validation_data)
  
      test_pairs = (
          np.arange(2 * each_set_size, 3 * each_set_size),
          np.arange(3 * each_set_size, 4 * each_set_size),
      )
      test_data = np.vstack(test_pairs).T.astype(np.int64)
      test_path = os.path.join("set", "test.npy")
      np.save(os.path.join(test_dir, test_path), test_data)
  
      yaml_content = f"""
          dataset_name: {dataset_name}
          graph: # graph structure and required attributes.
              nodes:
                  - num: {num_nodes}
              edges:
                  - format: {edge_fmt}
                    path: {edge_path}
              feature_data:
                  - domain: node
                    type: null
                    name: feat
                    format: numpy
                    in_memory: true
                    path: {node_feat_path}
                  - domain: edge
                    type: null
                    name: feat
                    format: numpy
                    in_memory: true
                    path: {edge_feat_path}
          feature_data:
              - domain: node
                type: null
                name: feat
                format: numpy
                in_memory: true
                path: {node_feat_path}
              - domain: edge
                type: null
                name: feat
                format: numpy
                path: {edge_feat_path}
          tasks:
            - name: link_prediction
              num_classes: {num_classes}
              train_set:
                - type: null
                  data:
                    - name: node_pairs
                      format: numpy
                      in_memory: true
                      path: {train_path}
              validation_set:
                - type: null
                  data:
                    - name: node_pairs
                      format: numpy
                      in_memory: true
                      path: {validation_path}
              test_set:
                - type: null
                  data:
                    - name: node_pairs
                      format: numpy
                      in_memory: true
                      path: {test_path}
      """
      return yaml_content
  
file_path: dgl/tests/python/pytorch/graphbolt/gb_test_utils.py
imports: import os
  import dgl
  import dgl.graphbolt
  import numpy
  import pandas
  import scipy.sparse
  import torch
label_desc: Use image node_id 6 for calling a global function with example usage: random_homo_graphbolt_graph(test_dir, dataset_name, num_nodes, num_edges, num_classes, edge_fmt) and returns: yaml_content