# Unipartite graph projection required for FastRPExtended

**URL:** <https://community.neo4j.com/t/unipartite-graph-projection-required-for-fastrpextended/40703>\
**Category:** Graph Data Science / Graph Analytics\
**Created:** [July 1, 2021, 4:29am UTC](https://community.neo4j.com/t/unipartite-graph-projection-required-for-fastrpextended/40703 "2021-07-01T04:29:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![stu\_v\_kerr](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/stu_v_kerr/32/691_2.png) [@stu\_v\_kerr](https://community.neo4j.com/u/stu_v_kerr)\
**Post date:** [July 1, 2021, 4:29am UTC](https://community.neo4j.com/t/unipartite-graph-projection-required-for-fastrpextended/40703/1 "2021-07-01T04:29:21Z")

</div>

The topic title is basically my question. I reviewed the fastRP documentation and it appears (implicitly) that a unipartite projection is required for both fastRP and fastRPExtended algorithms. Is this true?  
Even though the General configuration for algorithm execution on a named graph has the option to include Node Labels.

---

<div class="post-metadata">

**Author:** ![alicia\_frame1](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/alicia_frame1/32/6998_2.png) [@alicia\_frame1](https://community.neo4j.com/u/alicia_frame1)\
**Post date:** [July 1, 2021, 4:05pm UTC](https://community.neo4j.com/t/unipartite-graph-projection-required-for-fastrpextended/40703/2 "2021-07-01T16:05:34Z")

</div>

FastRP (and FastRPExtended) were originally designed with monopartite graphs in mind (1 node type / 1 relationship type).

It's possible to run them on heterogeneous graphs - theoretically, the embeddings themselves should encode that the nodes are different because the topology around different types of nodes is significantly different (eg. people & restaurants - people visit a few different restaurants, each restaurant is visited by many people).

You can also one hot encode the labels themselves as properties - which we do in graph sage. You'd add a property like `NodeLabel` with a vector of potential labels - `[0 1]` for restaurant, `[1 0]` for person etc. However, if you take this approach, you'll also need to pad out missing features (so say, people have ages, but restaurants don't, restaurants have a number of stars, people don't) by loading them into the in memory graph with a default value (like 0).

You'll have to tune them to make sure they distinguish the different types (try using node classification for a quick check, and adjusting accordingly), but they should be able to encode the information. Becuase they're not explicitly built for heterogeneous graphs (like ReScal or ComplEx), they won't be perfect, but they're a start - and much faster!

---

<div class="post-metadata">

**Author:** ![stu\_v\_kerr](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/stu_v_kerr/32/691_2.png) [@stu\_v\_kerr](https://community.neo4j.com/u/stu_v_kerr)\
**Post date:** [July 2, 2021, 3:57am UTC](https://community.neo4j.com/t/unipartite-graph-projection-required-for-fastrpextended/40703/3 "2021-07-02T03:57:52Z")

</div>

Thanks Alicia.  
I have a follow-up question regarding one hot encoding.  
Say I have a categorical property for a guest node, call the property guest.tier

There are multiple levels for tier (e.g., gold, silver, platinum, etc.,). I one hot encoded those tiers.

```auto
`MATCH (g:Guest) 
WITH collect(distinct g.tier) as tiers
MATCH (g1:Guest) 
SET g1.tierEmbedding = gds.alpha.ml.oneHotEncoding(tiers, [g1.tier])
RETURN count(*)`

```

So far so good. However, I want to use that one hot encoded property and others as `featureProperties` for the `fastRPExtended` algorithm. The `fastRPExtended` documentation notes that:  
`All property names must exist in the in-memory graph and be of type Float or List<Float>.`  
Is there a convenient way in cypher to convert the list of integers generated by the one hot encoding into floats so that it can be used as a `fastRPExtended` `featureProperty`?

I brute forced it this way:

```auto
MATCH (g:Guest) 
UNWIND g.tierEmbedding as x
with toFLoat(x) as newEmbeddingValue,g
with collect(newEmbeddingValue) as newEmbedding,g
set g.tierEmbedding = newEmbedding

```

---

<div class="post-metadata">

**Author:** ![frank.deviney](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/frank.deviney/32/15802_2.png) [@frank.deviney](https://community.neo4j.com/u/frank.deviney)\
**Post date:** [November 3, 2021, 2:53pm UTC](https://community.neo4j.com/t/unipartite-graph-projection-required-for-fastrpextended/40703/4 "2021-11-03T14:53:29Z")

</div>

I'd also like to know if casting to float is necessary.

---

<div class="post-metadata">

**Author:** ![alicia\_frame1](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/alicia_frame1/32/6998_2.png) [@alicia\_frame1](https://community.neo4j.com/u/alicia_frame1)\
**Post date:** [November 4, 2021, 4:48pm UTC](https://community.neo4j.com/t/unipartite-graph-projection-required-for-fastrpextended/40703/5 "2021-11-04T16:48:19Z")

</div>

I _think_ that will be fixed in our next release - available next thursday 🙂
