code: def testBiadjacency(self):
      g = Graph.Biadjacency([[0, 1, 1], [1, 2, 0]])
      self.assertTrue(
          all((g.vcount() == 5, g.ecount() == 4, not g.is_directed()))
      )
      self.assertListEqual(g.vs["type"], [False] * 2 + [True] * 3)
      self.assertListEqual(
          sorted(g.get_edgelist()), [(0, 3), (0, 4), (1, 2), (1, 3)]
      )
  
      g = Graph.Biadjacency([[0, 1, 1], [1, 2, 0]], multiple=True)
      self.assertTrue(
          all((g.vcount() == 5, g.ecount() == 5, not g.is_directed()))
      )
      self.assertListEqual(g.vs["type"], [False] * 2 + [True] * 3)
      self.assertListEqual(
          sorted(g.get_edgelist()),
          [(0, 3), (0, 4), (1, 2), (1, 3), (1, 3)],
      )
  
      g = Graph.Biadjacency([[0, 1, 1], [1, 2, 0]], directed=True)
      self.assertTrue(
          all((g.vcount() == 5, g.ecount() == 4, g.is_directed()))
      )
      self.assertListEqual(g.vs["type"], [False] * 2 + [True] * 3)
      self.assertListEqual(
          sorted(g.get_edgelist()), [(0, 3), (0, 4), (1, 2), (1, 3)]
      )
  
      g = Graph.Biadjacency(
          [[0, 1, 1], [1, 2, 0]], directed=True, mode="in"
      )
      self.assertTrue(
          all((g.vcount() == 5, g.ecount() == 4, g.is_directed()))
      )
      self.assertListEqual(g.vs["type"], [False] * 2 + [True] * 3)
      self.assertListEqual(
          sorted(g.get_edgelist()), [(2, 1), (3, 0), (3, 1), (4, 0)]
      )
  
      # Create a weighted Graph
      g = Graph.Biadjacency([[0, 1, 1], [1, 2, 0]], weighted=True)
      self.assertTrue(
          all(
              (
                  g.vcount() == 5,
                  g.ecount() == 4,
                  not g.is_directed(),
                  g.is_weighted(),
              )
          )
      )
      self.assertListEqual(g.vs["type"], [False] * 2 + [True] * 3)
      self.assertListEqual(g.es["weight"], [1, 1, 1, 2])
      self.assertListEqual(
          sorted(g.get_edgelist()), [(0, 3), (0, 4), (1, 2), (1, 3)]
      )
  
      # Graph is not weighted when weighted=`str`
      g = Graph.Biadjacency(
          [[0, 1, 1], [1, 2, 0]], weighted="some_attr_name"
      )
      self.assertTrue(
          all(
              (
                  g.vcount() == 5,
                  g.ecount() == 4,
                  not g.is_directed(),
                  not g.is_weighted(),
              )
          )
      )
      self.assertListEqual(g.vs["type"], [False] * 2 + [True] * 3)
      self.assertListEqual(g.es["some_attr_name"], [1, 1, 1, 2])
      self.assertListEqual(
          sorted(g.get_edgelist()), [(0, 3), (0, 4), (1, 2), (1, 3)]
      )
  
      # Graph is not weighted when weighted=""
      g = Graph.Biadjacency([[0, 1, 1], [1, 2, 0]], weighted="")
      self.assertTrue(
          all(
              (
                  g.vcount() == 5,
                  g.ecount() == 4,
                  not g.is_directed(),
                  not g.is_weighted(),
              )
          )
      )
      self.assertListEqual(g.vs["type"], [False] * 2 + [True] * 3)
      self.assertListEqual(g.es[""], [1, 1, 1, 2])
      self.assertListEqual(
          sorted(g.get_edgelist()), [(0, 3), (0, 4), (1, 2), (1, 3)]
      )
  
      # Should work when directed=True and mode=out with weighted
      g = Graph.Biadjacency(
          [[0, 1, 1], [1, 2, 0]], directed=True, weighted=True
      )
      self.assertTrue(
          all(
              (
                  g.vcount() == 5,
                  g.ecount() == 4,
                  g.is_directed(),
                  g.is_weighted(),
              )
          )
      )
      self.assertListEqual(g.vs["type"], [False] * 2 + [True] * 3)
      self.assertListEqual(g.es["weight"], [1, 1, 1, 2])
      self.assertListEqual(
          sorted(g.get_edgelist()), [(0, 3), (0, 4), (1, 2), (1, 3)]
      )
  
      # Should work when directed=True and mode=in with weighted
      g = Graph.Biadjacency(
          [[0, 1, 1], [1, 2, 0]],
          directed=True,
          mode="in",
          weighted=True,
      )
      self.assertTrue(
          all(
              (
                  g.vcount() == 5,
                  g.ecount() == 4,
                  g.is_directed(),
                  g.is_weighted(),
              )
          )
      )
      self.assertListEqual(g.vs["type"], [False] * 2 + [True] * 3)
      self.assertListEqual(g.es["weight"], [1, 1, 1, 2])
      self.assertListEqual(
          sorted(g.get_edgelist()), [(2, 1), (3, 0), (3, 1), (4, 0)]
      )
  
      # Should work when directed=True and mode=all with weighted
      g = Graph.Biadjacency(
          [[0, 1, 1], [1, 2, 0]],
          directed=True,
          mode="all",
          weighted=True,
      )
      self.assertTrue(
          all(
              (
                  g.vcount() == 5,
                  g.ecount() == 8,
                  g.is_directed(),
                  g.is_weighted(),
              )
          )
      )
      self.assertListEqual(g.vs["type"], [False] * 2 + [True] * 3)
      self.assertListEqual(g.es["weight"], [1, 1, 1, 1, 1, 1, 2, 2])
      self.assertListEqual(
          sorted(g.get_edgelist()),
          [
              (0, 3),
              (0, 4),
              (1, 2),
              (1, 3),
              (2, 1),
              (3, 0),
              (3, 1),
              (4, 0),
          ],
      )
  
file_path: python-igraph/tests/test_bipartite.py
imports: import unittest
  from igraph import Graph
label_desc: Use image node_id 3 for calling the BipartiteTests obj's underlying member method code with example usage: obj.testBiadjacency() without return types