Hi Abbasi,
Could you please confirm us that you want the expand & collapse functionality for the normal node or group node. If you want to normal basic shape node means then by using the ExpandICon and CollapseICon properties of the node we can able to do expand & collapse feature for the node. If you want expand and collapse feature for group node means then Currently we have expand & collapse functionality only for the normal node. We do not have support for the Expand & collapse functionality for the group node.
For more information about expand & collapse icon, please refer to the below UG documentation link
Regards
Aravind Ravi