# PetscSFSetGraphLayout
Set a parallel star forest via global indices and a `PetscLayout` 
## Synopsis
```
#include "petscsf.h"   
PetscErrorCode PetscSFSetGraphLayout(PetscSF sf, PetscLayout layout, PetscInt nleaves, PetscInt *ilocal, PetscCopyMode localmode, const PetscInt *gremote)
```
Collective


## Input Parameters

- ***sf -*** star forest
- ***layout -*** `PetscLayout` defining the global space for roots
- ***nleaves -*** number of leaf vertices on the current process, each of these references a root on any process
- ***ilocal -*** locations of leaves in leafdata buffers, pass NULL for contiguous storage
- ***localmode -*** copy mode for ilocal
- ***gremote -*** root vertices in global numbering corresponding to leaves in ilocal





## Note
Global indices must lie in [0, N) where N is the global size of layout.
Leaf indices in ilocal get sorted; this means the user-provided array gets sorted if localmode is `PETSC_OWN_POINTER`.


## Developer Note
Local indices which are the identity permutation in the range [0,nleaves) are discarded as they
encode contiguous storage. In such case, if localmode is `PETSC_OWN_POINTER`, the memory is deallocated as it is not
needed


## See Also
 `PetscSF`, `PetscSFGetGraphLayout()`, `PetscSFCreate()`, `PetscSFView()`, `PetscSFSetGraph()`, `PetscSFGetGraph()`

## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/is/sf/utils/sfutils.c.html#PetscSFSetGraphLayout">src/vec/is/sf/utils/sfutils.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/vec/is/sf/utils/sfutils.c)


[Index of all PetscSF routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
