Instead of using the filter function, you can simply unwrap it in multiple loops:
from dolfin import *
mesh = UnitSquareMesh(2, 2)
# Init facet-cell connectivity
tdim = mesh.topology().dim()
mesh.init(tdim - 1, tdim)
# For every cell, build a list of cells that are connected to its facets
# but are not the iterated cell
cell_neighbours = {}
for cell in cells(mesh):
index = cell.index()
cell_neighbours[index] = []
for facet in facets(cell):
facet_cells = facet.entities(tdim)
for facet_cell in facet_cells:
if (index!=facet_cell):
cell_neighbours[index].append(facet_cell)
print(cell_neighbours)