class_docstr: A data generator for link prediction with Homogeneous GraphSAGE models
  
  At minimum, supply the StellarGraph, the batch size, and the number of
  node samples for each layer of the GraphSAGE model.
  
  The supplied graph should be a StellarGraph object with node features.
  
  Use the :meth:`flow` method supplying the nodes and (optionally) targets,
  or an UnsupervisedSampler instance that generates node samples on demand,
  to get an object that can be used as a Keras data generator.
  
  Example::
  
      G_generator = GraphSAGELinkGenerator(G, 50, [10,10])
      train_data_gen = G_generator.flow(edge_ids)
  
  .. seealso::
  
     Model using this generator: :class:`.GraphSAGE`.
  
     Some examples using this generator (see the model for more):
  
     - `link prediction <https://stellargraph.readthedocs.io/en/stable/demos/link-prediction/graphsage-link-prediction.html>`__
     - `unsupervised representation learning via random walks <https://stellargraph.readthedocs.io/en/stable/demos/embeddings/graphsage-unsupervised-sampler-embeddings.html>`__
  
     Related functionality:
  
     - :class:`.UnsupervisedSampler` for unsupervised training using random walks
     - :class:`.GraphSAGENodeGenerator` for node classification and related tasks
     - :class:`.DirectedGraphSAGELinkGenerator` for directed graphs
     - :class:`.HinSAGELinkGenerator` for heterogeneous graphs
  
  Args:
      G (StellarGraph): A machine-learning ready graph.
      batch_size (int): Size of batch of links to return.
      num_samples (list): List of number of neighbour node samples per GraphSAGE layer (hop) to take.
      seed (int or str), optional: Random seed for the sampling methods.
      weighted (bool, optional): If True, sample neighbours using the edge weights in the graph.
class_docstr_tok: ["A","data","generator","for","link","prediction","with","Homogeneous","GraphSAGE","models","At","minimum",",","supply","the","StellarGraph",",","the","batch","size",",","and","the","number","of","node","samples","for","each","layer","of","the","GraphSAGE","model",".","The","supplied","graph","should","be","a","StellarGraph","object","with","node","features",".","Use","the",":","meth",":","`","flow","`","method","supplying","the","nodes","and","(","optionally",")","targets",",","or","an","UnsupervisedSampler","instance","that","generates","node","samples","on","demand",",","to","get","an","object","that","can","be","used","as","a","Keras","data","generator",".","Example",":",":","G_generator","=","GraphSAGELinkGenerator","(","G",",","50",",","[","10,10","]",")","train_data_gen","=","G_generator.flow","(","edge_ids",")","..","seealso",":",":","Model","using","this","generator",":",":","class",":","`",".GraphSAGE","`",".","Some","examples","using","this","generator","(","see","the","model","for","more",")",":","-","`","link","prediction","<","https",":","\/\/stellargraph.readthedocs.io\/en\/stable\/demos\/link-prediction\/graphsage-link-prediction.html",">","`","__","-","`","unsupervised","representation","learning","via","random","walks","<","https",":","\/\/stellargraph.readthedocs.io\/en\/stable\/demos\/embeddings\/graphsage-unsupervised-sampler-embeddings.html",">","`","__","Related","functionality",":","-",":","class",":","`",".UnsupervisedSampler","`","for","unsupervised","training","using","random","walks","-",":","class",":","`",".GraphSAGENodeGenerator","`","for","node","classification","and","related","tasks","-",":","class",":","`",".DirectedGraphSAGELinkGenerator","`","for","directed","graphs","-",":","class",":","`",".HinSAGELinkGenerator","`","for","heterogeneous","graphs","Args",":","G","(","StellarGraph",")",":","A","machine-learning","ready","graph",".","batch_size","(","int",")",":","Size","of","batch","of","links","to","return",".","num_samples","(","list",")",":","List","of","number","of","neighbour","node","samples","per","GraphSAGE","layer","(","hop",")","to","take",".","seed","(","int","or","str",")",",","optional",":","Random","seed","for","the","sampling","methods",".","weighted","(","bool",",","optional",")",":","If","True",",","sample","neighbours","using","the","edge","weights","in","the","graph","."]
code: def __init__(
      self,
      G,
      batch_size,
      num_samples,
      seed=None,
      name=None,
      weighted=False,
  ):
      super().__init__(G, batch_size)
  
      self.num_samples = num_samples
      self.name = name
      self.weighted = weighted
  
      # Check that there is only a single node type for GraphSAGE
      if len(self.schema.node_types) > 1:
          warnings.warn(
              "running homogeneous GraphSAGE on a graph with multiple node types",
              RuntimeWarning,
              stacklevel=2,
          )
  
      self.head_node_types = self.schema.node_types * 2
  
      self._graph = G
      self._samplers = SeededPerBatch(
          lambda s: SampledBreadthFirstWalk(
              self._graph, graph_schema=self.schema, seed=s
          ),
          seed=seed,
      )
  
imports: import random
  import operator
  import numpy
  import itertools
  import operator
  import collections
  import abc
  import warnings
  from functools import reduce
  from tensorflow import keras
  from ..core.graph import StellarGraph, GraphSchema
  from ..data import SampledBreadthFirstWalk, SampledHeterogeneousBreadthFirstWalk, UniformRandomWalk, UnsupervisedSampler, DirectedBreadthFirstNeighbours
  from ..core.utils import is_real_iterable
  from .None import LinkSequence, OnDemandLinkSequence
  from ..random import SeededPerBatch
  from .base import Generator
label_desc: Use image node_id 1 to create a new GraphSAGELinkGenerator object from inherited base classes: BatchedLinkGenerator with example: obj = GraphSAGELinkGenerator(G, batch_size, num_samples, seed, name, weighted)